From 7270c66a91fe8cd949a405cb274131287995d828 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Sat, 9 Jul 2022 16:35:43 -0500 Subject: [PATCH] Fix focus input bug --- web/hooks/use-focus.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web/hooks/use-focus.ts b/web/hooks/use-focus.ts index a71a0292..f41f46a7 100644 --- a/web/hooks/use-focus.ts +++ b/web/hooks/use-focus.ts @@ -1,11 +1,12 @@ import { useRef } from 'react' +import { useEvent } from './use-event' // Focus helper from https://stackoverflow.com/a/54159564/1222351 export function useFocus(): [React.RefObject, () => void] { const htmlElRef = useRef(null) - const setFocus = () => { + const setFocus = useEvent(() => { htmlElRef.current && htmlElRef.current.focus() - } + }) return [htmlElRef, setFocus] }