From edfa7dc26d5488aa220f4775564f3c49782e789a Mon Sep 17 00:00:00 2001 From: thomasgross Date: Wed, 15 Jan 2025 16:23:17 +0100 Subject: [PATCH] refactor: change keydown handling in SearchInput component to navigate using input ref value --- components/shared/searchInput/SearchInput.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/shared/searchInput/SearchInput.tsx b/components/shared/searchInput/SearchInput.tsx index e54316c..8d282ac 100644 --- a/components/shared/searchInput/SearchInput.tsx +++ b/components/shared/searchInput/SearchInput.tsx @@ -31,14 +31,13 @@ const SearchInput = ({ className, placeholder }: SearchInputProps) => { // We choose to ignore the eslint warning below // because we do not want to add the handleKeydown callback which changes on every render. // eslint-disable-next-line react-hooks/exhaustive-deps - }, [currentQuery]) + }, []) const handleKeydown = () => (event: KeyboardEvent) => { - if (!currentQuery) return const focusedElement = document.activeElement as HTMLElement if (event.key === "Enter" && focusedElement === inputRef.current) { - navigateToSearch(currentQuery) + navigateToSearch(inputRef.current.value) } }