From a3907918e4aaff9632334d0561d6b17664b0f1df Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 11 Sep 2022 15:48:45 +0100 Subject: [PATCH] fix: CMD+F twice should allow page search closes #4105 --- app/components/InputSearchPage.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/components/InputSearchPage.tsx b/app/components/InputSearchPage.tsx index 347dec37f..289673688 100644 --- a/app/components/InputSearchPage.tsx +++ b/app/components/InputSearchPage.tsx @@ -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);