From d408ccbd418c6fbe530faf288b3f6700df9e44c8 Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 14 Jan 2021 20:31:00 -0600 Subject: [PATCH] users: remove option to disable autocomplete. This option was originally added in issue #1747. But only ~350 users ever disabled autocomplete, only ~120 of these were seen in the last year, and only 9 new users who signed up in the last year disabled it. Users wishing to disable autocomplete can use this CSS: .ui-autocomplete { display: none !important: } or this Javascript: $("[data-autocomplete]").autocomplete("disable"); --- CHANGELOG.md | 2 + app/helpers/application_helper.rb | 4 +- .../src/javascripts/autocomplete.js.erb | 58 +++++++++---------- .../src/javascripts/post_mode_menu.js | 5 +- app/javascript/src/javascripts/posts.js.erb | 4 +- app/models/user.rb | 1 - app/policies/user_policy.rb | 9 ++- app/views/users/edit.html.erb | 1 - 8 files changed, 38 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9133108b..1c191d183 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ * Removed the option to disable keyboard shortcuts. +* Removed the option to disable tag autocomplete. + ## 2021-01-12 ### Changes diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4dfd9e9cf..4cd08bc03 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -289,8 +289,8 @@ module ApplicationHelper %i[ id name level level_string theme always_resize_images can_upload_free can_approve_posts disable_categorized_saved_searches - disable_mobile_gestures disable_post_tooltips enable_auto_complete - enable_safe_mode hide_deleted_posts show_deleted_children style_usernames + disable_mobile_gestures disable_post_tooltips enable_safe_mode + hide_deleted_posts show_deleted_children style_usernames default_image_size ] + User::Roles.map { |role| :"is_#{role}?" } end diff --git a/app/javascript/src/javascripts/autocomplete.js.erb b/app/javascript/src/javascripts/autocomplete.js.erb index c3269f358..7f94c924d 100644 --- a/app/javascript/src/javascripts/autocomplete.js.erb +++ b/app/javascript/src/javascripts/autocomplete.js.erb @@ -10,37 +10,35 @@ Autocomplete.TAG_PREFIXES = "-|~|" + Object.keys(Autocomplete.TAG_CATEGORIES).ma Autocomplete.MAX_RESULTS = 10; Autocomplete.initialize_all = function() { - if (CurrentUser.data("enable-auto-complete")) { - $.widget("ui.autocomplete", $.ui.autocomplete, { - options: { - delay: 0, - minLength: 1, - autoFocus: false, - focus: function() { return false; }, - }, - _create: function() { - this.element.on("keydown.Autocomplete.tab", null, "tab", Autocomplete.on_tab); - this._super(); - }, - _renderItem: Autocomplete.render_item, - search: function(value, event) { - if ($(this).data("ui-autocomplete")) { - $(this).data("ui-autocomplete").menu.bindings = $(); - } - this._super(value, event); - }, - }); + $.widget("ui.autocomplete", $.ui.autocomplete, { + options: { + delay: 0, + minLength: 1, + autoFocus: false, + focus: function() { return false; }, + }, + _create: function() { + this.element.on("keydown.Autocomplete.tab", null, "tab", Autocomplete.on_tab); + this._super(); + }, + _renderItem: Autocomplete.render_item, + search: function(value, event) { + if ($(this).data("ui-autocomplete")) { + $(this).data("ui-autocomplete").menu.bindings = $(); + } + this._super(value, event); + }, + }); - this.initialize_tag_autocomplete(); - this.initialize_mention_autocomplete($("form div.input.dtext textarea")); - this.initialize_fields($('[data-autocomplete="tag"]'), "tag"); - this.initialize_fields($('[data-autocomplete="artist"]'), "artist"); - this.initialize_fields($('[data-autocomplete="pool"]'), "pool"); - this.initialize_fields($('[data-autocomplete="user"]'), "user"); - this.initialize_fields($('[data-autocomplete="wiki-page"]'), "wiki_page"); - this.initialize_fields($('[data-autocomplete="favorite-group"]'), "favorite_group"); - this.initialize_fields($('[data-autocomplete="saved-search-label"]'), "saved_search_label"); - } + this.initialize_tag_autocomplete(); + this.initialize_mention_autocomplete($("form div.input.dtext textarea")); + this.initialize_fields($('[data-autocomplete="tag"]'), "tag"); + this.initialize_fields($('[data-autocomplete="artist"]'), "artist"); + this.initialize_fields($('[data-autocomplete="pool"]'), "pool"); + this.initialize_fields($('[data-autocomplete="user"]'), "user"); + this.initialize_fields($('[data-autocomplete="wiki-page"]'), "wiki_page"); + this.initialize_fields($('[data-autocomplete="favorite-group"]'), "favorite_group"); + this.initialize_fields($('[data-autocomplete="saved-search-label"]'), "saved_search_label"); } Autocomplete.initialize_fields = function($fields, type) { diff --git a/app/javascript/src/javascripts/post_mode_menu.js b/app/javascript/src/javascripts/post_mode_menu.js index 0f29547ae..d1f3fa871 100644 --- a/app/javascript/src/javascripts/post_mode_menu.js +++ b/app/javascript/src/javascripts/post_mode_menu.js @@ -1,4 +1,3 @@ -import CurrentUser from './current_user' import Post from './posts.js.erb' import Utility from './utility' @@ -77,9 +76,7 @@ PostModeMenu.initialize_edit_form = function() { PostModeMenu.close_edit_form = function() { $("#quick-edit-div").slideUp("fast"); - if (CurrentUser.data("enable-auto-complete")) { - $("#post_tag_string").data("uiAutocomplete").close(); - } + $("#post_tag_string").data("uiAutocomplete").close(); } PostModeMenu.initialize_tag_script_field = function() { diff --git a/app/javascript/src/javascripts/posts.js.erb b/app/javascript/src/javascripts/posts.js.erb index c1f5e4074..8963aa31b 100644 --- a/app/javascript/src/javascripts/posts.js.erb +++ b/app/javascript/src/javascripts/posts.js.erb @@ -117,9 +117,7 @@ Post.open_edit_dialog = function() { of: window }, drag: function(e, ui) { - if (CurrentUser.data("enable-auto-complete")) { - $tag_string.data("uiAutocomplete").close(); - } + $tag_string.data("uiAutocomplete").close(); }, close: Post.close_edit_dialog }); diff --git a/app/models/user.rb b/app/models/user.rb index b042a1f6c..b5c8c39f2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -698,7 +698,6 @@ class User < ApplicationRecord def initialize_attributes self.new_post_navigation_layout = true - self.enable_auto_complete = true self.always_resize_images = true end diff --git a/app/policies/user_policy.rb b/app/policies/user_policy.rb index 28b02f1aa..f065c4668 100644 --- a/app/policies/user_policy.rb +++ b/app/policies/user_policy.rb @@ -45,11 +45,10 @@ class UserPolicy < ApplicationPolicy :blacklisted_tags, :time_zone, :per_page, :custom_style, :theme, :receive_email_notifications, :always_resize_images, :new_post_navigation_layout, :enable_private_favorites, - :hide_deleted_posts, :style_usernames, :enable_auto_complete, - :show_deleted_children, :disable_categorized_saved_searches, - :disable_tagged_filenames, :disable_cropped_thumbnails, - :disable_mobile_gestures, :enable_safe_mode, :enable_desktop_mode, - :disable_post_tooltips, + :hide_deleted_posts, :style_usernames, :show_deleted_children, + :disable_categorized_saved_searches, :disable_tagged_filenames, + :disable_cropped_thumbnails, :disable_mobile_gestures, :enable_safe_mode, + :enable_desktop_mode, :disable_post_tooltips, ].compact end diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index a249a7942..0c4e32fc8 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -62,7 +62,6 @@ <%= f.input :new_post_navigation_layout, :as => :select, :label => "Navigation bar position", :include_blank => false, :collection => [["Below", "true"], ["Above", "false"]], :hint => "When browsing pools or posts, place navigation links above or below the image" %> <%= f.input :hide_deleted_posts, :as => :select, :label => "Deleted post filter", :hint => "Remove deleted posts from search results", :include_blank => false, :collection => [["Yes", "true"], ["No", "false"]] %> <%= f.input :show_deleted_children, :as => :select, :label => "Show deleted children", :hint => "Show thumbnail borders on parent posts even if the children are deleted", :include_blank => false, :collection => [["Yes", "true"], ["No", "false"]] %> - <%= f.input :enable_auto_complete, :as => :select, :hint => "Enable tag autocomplete in the search box", :collection => [["Yes", "true"], ["No", "false"]], :include_blank => false %> <%= f.input :disable_categorized_saved_searches, :hint => "Don't show dialog box when creating a new saved search", :as => :select, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false %> <%= f.input :enable_private_favorites, :as => :select, :hint => "Make your favorites private", :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false %> <%= f.input :disable_tagged_filenames, :as => :select, :hint => "Don't include tags in image filenames", :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false %>