From 5ca70ca17e54bf05b507ff40e9b4e10c7fc8c286 Mon Sep 17 00:00:00 2001 From: Amit Katyal <89385446+amit-katyal@users.noreply.github.com> Date: Wed, 20 Aug 2025 15:38:54 +0530 Subject: [PATCH] [feat] client/simple: move cursor to end of search input on mobile On mobile devices, when the search input is focused, move the cursor to the end of the existing text. This improves the user experience by making it easier to edit or append to the current query without manually moving the cursor first. Closes: https://github.com/searxng/searxng/issues/5112 --- client/simple/src/js/main/search.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/client/simple/src/js/main/search.ts b/client/simple/src/js/main/search.ts index cbf41a205..c7ce9e090 100644 --- a/client/simple/src/js/main/search.ts +++ b/client/simple/src/js/main/search.ts @@ -40,6 +40,18 @@ if (!(isMobile || isResultsPage)) { qInput.focus(); } +// On mobile, move cursor to the end of the input on focus +if (isMobile) { + listen("focus", qInput, () => { + // Defer cursor move until the next frame to prevent a visual jump + requestAnimationFrame(() => { + const end = qInput.value.length; + qInput.setSelectionRange(end, end); + qInput.scrollLeft = qInput.scrollWidth; + }); + }); +} + createClearButton(qInput); // Additionally to searching when selecting a new category, we also