From 70eae7467cd31681130e5d7b5ea78f77ddc3a554 Mon Sep 17 00:00:00 2001 From: Bram Suurd <78373894+BramSuurdje@users.noreply.github.com> Date: Fri, 3 May 2024 20:21:00 +0200 Subject: [PATCH] Fix focus issue in Page component when using "/" shortcut --- app/page.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index c092818..b0e8091 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -33,12 +33,14 @@ export default function Page() { const [links, setLinks] = useState([]); const [searchTerm, setSearchTerm] = useState(""); const [accordionExpanded, setAccordionExpanded] = useState(false); - const inputRef = useRef(); + const inputRef = useRef(null); useEffect(() => { const handleKeyDown = (event: any) => { if (event.key === "/") { - inputRef.current.focus(); + if (inputRef.current) { + inputRef.current.focus(); + } event.preventDefault(); } };