fix(labs): leave "/" to the browser when no search field is on screen

The shortcut called preventDefault before checking for the field, so on
a labs or documents page still loading, in error, or with nothing
recorded, "/" did nothing and the browser lost its own use of the key.
This commit is contained in:
Marc-André Bombeck committed 2026-11-11 00:48:16 +01:00
1 parent ee1eb921a9
commit b4a5442fb5
3 files changed
+61 -2

No files matched your search

@@ -62,8 +62,12 @@ export function useVaultFilters() {
) {
return;
}
// No field on screen (loading, an error, nothing recorded yet): the
// key stays the browser's.
const input = searchInputRef.current;
if (!input || !input.isConnected) return;
event.preventDefault();
searchInputRef.current?.focus();
input.focus();
};
window.addEventListener("keydown", onKeyDown);
return () => window.removeEventListener("keydown", onKeyDown);