search key nav fixes 3
All checks were successful
Build Org Website / build (push) Successful in 44s
All checks were successful
Build Org Website / build (push) Successful in 44s
This commit is contained in:
@@ -196,8 +196,11 @@ function isSearchOpen() {
|
||||
}
|
||||
|
||||
function focusPaneInput() {
|
||||
paneInput.focus({ preventScroll: true });
|
||||
paneInput.setSelectionRange(paneInput.value.length, paneInput.value.length);
|
||||
if (!isSearchOpen()) return;
|
||||
paneInput.focus();
|
||||
try {
|
||||
paneInput.setSelectionRange(paneInput.value.length, paneInput.value.length);
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
function openSearchPane(initialValue = "") {
|
||||
@@ -213,6 +216,7 @@ function openSearchPane(initialValue = "") {
|
||||
|
||||
focusPaneInput();
|
||||
window.requestAnimationFrame(focusPaneInput);
|
||||
window.setTimeout(focusPaneInput, 0);
|
||||
}
|
||||
|
||||
function closeSearchPane() {
|
||||
@@ -388,10 +392,17 @@ function shouldUseSlashShortcut(event) {
|
||||
}
|
||||
|
||||
if (searchInput && searchBtn && paneInput && modalResults && paneCount) {
|
||||
const keepFocusForModal = (e) => e.preventDefault();
|
||||
const openFromHeaderControl = (e) => {
|
||||
e.preventDefault();
|
||||
openSearchPane(searchInput.value);
|
||||
};
|
||||
|
||||
searchInput.addEventListener("pointerdown", keepFocusForModal);
|
||||
searchInput.addEventListener("focus", () => {
|
||||
if (!suppressHeaderFocus) openSearchPane(searchInput.value);
|
||||
});
|
||||
searchInput.addEventListener("click", () => openSearchPane(searchInput.value));
|
||||
searchInput.addEventListener("click", openFromHeaderControl);
|
||||
|
||||
searchInput.addEventListener("input", () => {
|
||||
if (isSyncingHeaderInput) return;
|
||||
@@ -408,7 +419,8 @@ if (searchInput && searchBtn && paneInput && modalResults && paneCount) {
|
||||
paneInput.addEventListener("keydown", handleSearchKeydown);
|
||||
modalResults.addEventListener("keydown", handleSearchKeydown);
|
||||
|
||||
searchBtn.addEventListener("click", () => openSearchPane(searchInput.value));
|
||||
searchBtn.addEventListener("pointerdown", keepFocusForModal);
|
||||
searchBtn.addEventListener("click", openFromHeaderControl);
|
||||
|
||||
modal.addEventListener("click", (e) => {
|
||||
if (e.target.hasAttribute("data-search-close")) {
|
||||
|
||||
Reference in New Issue
Block a user