From 8e742b2549bbd3e2b68d79dabfd8133627848c0d Mon Sep 17 00:00:00 2001 From: KoloMl Date: Thu, 14 Nov 2024 22:43:43 +0400 Subject: [PATCH] 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; }