diff options
| author | Amit Katyal <89385446+amit-katyal@users.noreply.github.com> | 2025-08-20 15:38:54 +0530 |
|---|---|---|
| committer | Markus Heiser <markus.heiser@darmarIT.de> | 2025-08-21 14:04:13 +0200 |
| commit | 5ca70ca17e54bf05b507ff40e9b4e10c7fc8c286 (patch) | |
| tree | 8be9e4e722ceab7ac099de648802f96879f84f59 /client/simple/src | |
| parent | 22c2c9327406fc5acea0517ae7b589cc30b5f724 (diff) | |
[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
Diffstat (limited to 'client/simple/src')
| -rw-r--r-- | client/simple/src/js/main/search.ts | 12 |
1 files changed, 12 insertions, 0 deletions
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 |