search key nav fixes 4
All checks were successful
Build Org Website / build (push) Successful in 43s

This commit is contained in:
gitea-actions
2026-05-14 14:39:13 +01:00
parent 314ca414b3
commit c435a7eb78
3 changed files with 20 additions and 6 deletions

View File

@@ -197,12 +197,20 @@ function isSearchOpen() {
function focusPaneInput() {
if (!isSearchOpen()) return;
paneInput.focus();
paneInput.focus({ preventScroll: true });
try {
paneInput.setSelectionRange(paneInput.value.length, paneInput.value.length);
} catch (_) {}
}
function schedulePaneInputFocus() {
focusPaneInput();
window.requestAnimationFrame(() => {
focusPaneInput();
window.requestAnimationFrame(focusPaneInput);
});
}
function openSearchPane(initialValue = "") {
const value = initialValue || searchInput?.value || paneInput?.value || "";
@@ -214,9 +222,7 @@ function openSearchPane(initialValue = "") {
setHeaderSearchValue(value);
renderResults(value);
focusPaneInput();
window.requestAnimationFrame(focusPaneInput);
window.setTimeout(focusPaneInput, 0);
schedulePaneInputFocus();
}
function closeSearchPane() {
@@ -249,7 +255,7 @@ function updateActiveResult(focusActive = false) {
block: "nearest",
behavior: "smooth",
});
if (focusActive) items[activeIndex].focus({ preventScroll: true });
if (focusActive) focusPaneInput();
}
}