From 0523c0f400a502aeb6597621abf9588eba3e2933 Mon Sep 17 00:00:00 2001 From: KoloMl Date: Thu, 14 Nov 2024 22:33:10 +0400 Subject: [PATCH 1/2] Fixed search fields resetting to the last term instead of the query --- assets/js/autocomplete.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/assets/js/autocomplete.ts b/assets/js/autocomplete.ts index 489392c3..6a8c560e 100644 --- a/assets/js/autocomplete.ts +++ b/assets/js/autocomplete.ts @@ -25,6 +25,7 @@ function restoreOriginalValue() { if (isSearchField(inputField) && originalQuery) { inputField.value = originalQuery; + return; } if (originalTerm) { From 8e742b2549bbd3e2b68d79dabfd8133627848c0d Mon Sep 17 00:00:00 2001 From: KoloMl Date: Thu, 14 Nov 2024 22:43:43 +0400 Subject: [PATCH 2/2] Move selection to end of the selected term instead of the end of query --- assets/js/autocomplete.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/assets/js/autocomplete.ts b/assets/js/autocomplete.ts index 6a8c560e..61340b48 100644 --- a/assets/js/autocomplete.ts +++ b/assets/js/autocomplete.ts @@ -25,6 +25,13 @@ function restoreOriginalValue() { if (isSearchField(inputField) && originalQuery) { inputField.value = originalQuery; + + if (selectedTerm) { + const [, selectedTermEnd] = selectedTerm[0]; + + inputField.setSelectionRange(selectedTermEnd, selectedTermEnd); + } + return; }