mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 07:42:23 +00:00
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:
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);
|
||||
|
||||
Reference in new issue
Block a user