mirror of
https://github.com/searxng/searxng.git
synced 2025-09-03 20:13:50 +00:00
[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
This commit is contained in:
parent
22c2c93274
commit
5ca70ca17e
1 changed files with 12 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue