diff --git a/assets/js/autocomplete.js b/assets/js/autocomplete.js index 758754dd..1b7c6fd8 100644 --- a/assets/js/autocomplete.js +++ b/assets/js/autocomplete.js @@ -188,11 +188,16 @@ function getSelectedTerm() { } function toggleSearchAutocomplete() { - if (!store.get('disable_search_ac')) return; + const enable = store.get('enable_search_ac'); for (const searchField of document.querySelectorAll('input[data-ac-mode=search]')) { - searchField.removeAttribute('data-ac'); - searchField.autocomplete = 'on'; + if (enable) { + searchField.autocomplete = 'off'; + } + else { + searchField.removeAttribute('data-ac'); + searchField.autocomplete = 'on'; + } } } diff --git a/lib/philomena_web/controllers/setting_controller.ex b/lib/philomena_web/controllers/setting_controller.ex index e9241d1c..64118a45 100644 --- a/lib/philomena_web/controllers/setting_controller.ex +++ b/lib/philomena_web/controllers/setting_controller.ex @@ -45,7 +45,7 @@ defmodule PhilomenaWeb.SettingController do |> set_cookie(user_params, "hide_uploader", "hide_uploader") |> set_cookie(user_params, "hide_score", "hide_score") |> set_cookie(user_params, "unfilter_tag_suggestions", "unfilter_tag_suggestions") - |> set_cookie(user_params, "disable_search_ac", "disable_search_ac") + |> set_cookie(user_params, "enable_search_ac", "enable_search_ac") end defp set_cookie(conn, params, param_name, cookie_name) do diff --git a/lib/philomena_web/templates/layout/_header.html.slime b/lib/philomena_web/templates/layout/_header.html.slime index 60aa3b6f..0cf9fc2e 100644 --- a/lib/philomena_web/templates/layout/_header.html.slime +++ b/lib/philomena_web/templates/layout/_header.html.slime @@ -12,7 +12,7 @@ header.header i.fa.fa-upload = form_for @conn, ~p"/search", [method: "get", class: "header__search flex flex--no-wrap flex--centered", enforce_utf8: false], fn f -> - input.input.header__input.header__input--search#q name="q" title="For terms all required, separate with ',' or 'AND'; also supports 'OR' for optional terms and '-' or 'NOT' for negation. Search with a blank query for more options or click the ? for syntax help." value=@conn.params["q"] placeholder="Search" autocapitalize="none" autocomplete="off" data-ac="true" data-ac-min-length="3" data-ac-mode="search" + input.input.header__input.header__input--search#q name="q" title="For terms all required, separate with ',' or 'AND'; also supports 'OR' for optional terms and '-' or 'NOT' for negation. Search with a blank query for more options or click the ? for syntax help." value=@conn.params["q"] placeholder="Search" autocapitalize="none" data-ac="true" data-ac-min-length="3" data-ac-mode="search" = if present?(@conn.params["sf"]) do input type="hidden" name="sf" value=@conn.params["sf"] diff --git a/lib/philomena_web/templates/setting/edit.html.slime b/lib/philomena_web/templates/setting/edit.html.slime index a61d6307..d2ef4027 100644 --- a/lib/philomena_web/templates/setting/edit.html.slime +++ b/lib/philomena_web/templates/setting/edit.html.slime @@ -175,9 +175,9 @@ h1 Content Settings => checkbox f, :chan_nsfw, checked: @conn.cookies["chan_nsfw"] == "true" .fieldlabel: i Show streams marked as NSFW on the channels page. .field - => label f, :disable_search_ac, "Disable search auto-completion" - => checkbox f, :disable_search_ac, checked: @conn.cookies["disable_search_ac"] === "true" - .fieldlabel: i Disable the auto-completion of tags in the search fields. This will bring back default browser's behaviour. + => label f, :enable_search_ac, "Enable search auto-completion" + => checkbox f, :enable_search_ac, checked: @conn.cookies["enable_search_ac"] === "true" + .fieldlabel: i Enable the auto-completion of tags in search fields. = if staff?(@conn.assigns.current_user) do .field => label f, :hide_staff_tools