Search UI tweaks (#13965)

* Prevent keyboard shortcuts from running when input is focused

* fix reset button and update time pickers when using input

* simplify css

* consistent button order and spacing
This commit is contained in:
Josh Hawkins
2024-09-25 13:45:42 -05:00
committed by GitHub
parent fef30bc671
commit 32c7669b28
5 changed files with 56 additions and 43 deletions

View File

@@ -10,6 +10,7 @@ export type KeyModifiers = {
export default function useKeyboardListener(
keys: string[],
listener: (key: string | null, modifiers: KeyModifiers) => void,
preventDefault: boolean = true,
) {
const keyDownListener = useCallback(
(e: KeyboardEvent) => {
@@ -25,13 +26,13 @@ export default function useKeyboardListener(
};
if (keys.includes(e.key)) {
e.preventDefault();
if (preventDefault) e.preventDefault();
listener(e.key, modifiers);
} else if (e.key === "Shift" || e.key === "Control" || e.key === "Meta") {
listener(null, modifiers);
}
},
[keys, listener],
[keys, listener, preventDefault],
);
const keyUpListener = useCallback(