search key nav fixes 4
All checks were successful
Build Org Website / build (push) Successful in 43s
All checks were successful
Build Org Website / build (push) Successful in 43s
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user