refactor: encapsulate search state, bound cache

This commit is contained in:
2026-06-16 01:00:32 +02:00
committed by Milas Holsting
parent 3c30688058
commit 31a8da10b4
5 changed files with 197 additions and 77 deletions

View File

@@ -1,5 +1,4 @@
import {
state,
commandPaletteInitializedKey,
globalWindow,
searchInput,
@@ -10,6 +9,7 @@ import {
searchCloseButtons,
searchClearButtons,
searchDialog,
getSelectedIndex,
isSearchOpen,
isTypingTarget,
} from "./state";
@@ -26,13 +26,13 @@ const onDocumentClick = (event: MouseEvent): void => {
const onInputKeydown = (event: KeyboardEvent): void => {
if (event.key === "ArrowDown") {
event.preventDefault();
selectItem(state.selectedIndex + 1, true);
selectItem(getSelectedIndex() + 1, true);
return;
}
if (event.key === "ArrowUp") {
event.preventDefault();
selectItem(state.selectedIndex - 1, true);
selectItem(getSelectedIndex() - 1, true);
return;
}