fix: CMD+F twice should allow page search

closes #4105
This commit is contained in:
Tom Moor
2022-09-11 15:48:45 +01:00
parent afc7fb5f1d
commit a3907918e4

View File

@@ -35,14 +35,11 @@ function InputSearchPage({
const history = useHistory();
const { t } = useTranslation();
const [isFocused, setFocused, setUnfocused] = useBoolean(false);
const focus = React.useCallback(() => {
inputRef.current?.focus();
}, []);
useKeyDown("f", (ev: KeyboardEvent) => {
if (isModKey(ev)) {
if (isModKey(ev) && document.activeElement !== inputRef.current) {
ev.preventDefault();
focus();
inputRef.current?.focus();
}
});
@@ -57,6 +54,10 @@ function InputSearchPage({
})
);
}
if (ev.key === "Escape") {
ev.preventDefault();
inputRef.current?.blur();
}
if (onKeyDown) {
onKeyDown(ev);