diff --git a/web/src/components/filter/SearchFilterGroup.tsx b/web/src/components/filter/SearchFilterGroup.tsx index 54618aefc..09d38c442 100644 --- a/web/src/components/filter/SearchFilterGroup.tsx +++ b/web/src/components/filter/SearchFilterGroup.tsx @@ -430,6 +430,13 @@ function TimeRangeFilterButton({ const formattedSelectedAfter = useFormattedHour(config, selectedAfterHour); const formattedSelectedBefore = useFormattedHour(config, selectedBeforeHour); + useEffect(() => { + setSelectedAfterHour(afterHour); + setSelectedBeforeHour(beforeHour); + // only refresh when state changes + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [timeRange]); + const trigger = ( - + - +
)} -
- +
+
); diff --git a/web/src/hooks/use-keyboard-listener.tsx b/web/src/hooks/use-keyboard-listener.tsx index ad9462a05..ad776b303 100644 --- a/web/src/hooks/use-keyboard-listener.tsx +++ b/web/src/hooks/use-keyboard-listener.tsx @@ -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( diff --git a/web/src/views/search/SearchView.tsx b/web/src/views/search/SearchView.tsx index 28f9ed579..3677612c7 100644 --- a/web/src/views/search/SearchView.tsx +++ b/web/src/views/search/SearchView.tsx @@ -209,9 +209,11 @@ export default function SearchView({ // keyboard listener + const [inputFocused, setInputFocused] = useState(false); + const onKeyboardShortcut = useCallback( (key: string | null, modifiers: KeyModifiers) => { - if (!modifiers.down || !uniqueResults) { + if (!modifiers.down || !uniqueResults || inputFocused) { return; } @@ -236,10 +238,14 @@ export default function SearchView({ break; } }, - [uniqueResults], + [uniqueResults, inputFocused], ); - useKeyboardListener(["ArrowLeft", "ArrowRight"], onKeyboardShortcut); + useKeyboardListener( + ["ArrowLeft", "ArrowRight"], + onKeyboardShortcut, + !inputFocused, + ); // scroll into view @@ -310,6 +316,8 @@ export default function SearchView({ {config?.semantic_search?.enabled && (