From 9dd26f2f876afe9ea9a06543f82c195e2243550e Mon Sep 17 00:00:00 2001 From: KoloMl Date: Sun, 2 Jun 2024 19:58:01 +0400 Subject: [PATCH] Added separate property to control autocompletion mode This is better than using hardcoded field name. --- assets/js/autocomplete.js | 2 +- lib/philomena_web/templates/layout/_header.html.slime | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/js/autocomplete.js b/assets/js/autocomplete.js index 9ac4c2b8..28c0f409 100644 --- a/assets/js/autocomplete.js +++ b/assets/js/autocomplete.js @@ -27,7 +27,7 @@ function removeSelected() { } function isSearchField() { - return inputField && inputField.name === 'q'; + return inputField && inputField.dataset.acMode === 'search'; } function restoreOriginalValue() { diff --git a/lib/philomena_web/templates/layout/_header.html.slime b/lib/philomena_web/templates/layout/_header.html.slime index ea268bf3..406728ff 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, Routes.search_path(@conn, :index), [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-source="/autocomplete/tags?term=" + 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-source="/autocomplete/tags?term=" data-ac-mode="search" = if present?(@conn.params["sf"]) do input type="hidden" name="sf" value=@conn.params["sf"]