diff --git a/assets/js/search_autocomplete.js b/assets/js/search_autocomplete.js index 78036a7af..650e915c8 100644 --- a/assets/js/search_autocomplete.js +++ b/assets/js/search_autocomplete.js @@ -248,6 +248,8 @@ function getAutocompleteSource() { } function setupSearchAutocomplete() { + if (store.get('disable_search_ac')) return; + const fields = $$('.js-search-field'); fields.forEach(field => { diff --git a/assets/js/settings.js b/assets/js/settings.js index 7a6d195e0..360228eea 100644 --- a/assets/js/settings.js +++ b/assets/js/settings.js @@ -15,11 +15,8 @@ export function setupSettings() { // Local settings localCheckboxes.forEach(checkbox => { - const storeKey = checkbox.id.replace('user_', ''); - checkbox.checked = store.get(storeKey); - checkbox.addEventListener('change', () => { - store.set(storeKey, checkbox.checked); + store.set(checkbox.id.replace('user_', ''), checkbox.checked); }); }); diff --git a/lib/philomena_web/controllers/setting_controller.ex b/lib/philomena_web/controllers/setting_controller.ex index 3d55ebdd1..892d9969e 100644 --- a/lib/philomena_web/controllers/setting_controller.ex +++ b/lib/philomena_web/controllers/setting_controller.ex @@ -43,6 +43,7 @@ defmodule PhilomenaWeb.SettingController do |> set_cookie(user_params, "hide_staff_tools", "hide_staff_tools") |> set_cookie(user_params, "hide_uploader", "hide_uploader") |> set_cookie(user_params, "extended_search_ac", "extended_search_ac") + |> set_cookie(user_params, "disable_search_ac", "disable_search_ac") end defp set_cookie(conn, params, param_name, cookie_name) do diff --git a/lib/philomena_web/templates/setting/edit.html.slime b/lib/philomena_web/templates/setting/edit.html.slime index eacf36c46..f23cab1af 100644 --- a/lib/philomena_web/templates/setting/edit.html.slime +++ b/lib/philomena_web/templates/setting/edit.html.slime @@ -118,9 +118,13 @@ h1 Content Settings => label f, :chan_nsfw, "Show NSFW channels" => 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 tag autocompletion on search inputs" + => checkbox f, :disable_search_ac, checked: @conn.cookies["disable_search_ac"] == "true" + .fieldlabel: i By default the various image search inputs across the site will give you tag suggestions as you type. You can disable this here to revert to the previous behavior. .field => label f, :extended_search_ac, "Autocomplete search fields using extended syntax" - => checkbox f, :extended_search_ac, checked: @conn.cookies["chan_nsfw"] == "true" + => checkbox f, :extended_search_ac, checked: @conn.cookies["extended_search_ac"] == "true" .fieldlabel i | By default the search fields on the site autocomplete the same syntax as the tag input, but you can chose to enable the