From 9d6d70d21f86942732870c5aca536d43c1aa1c97 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 27 Oct 2024 08:37:26 +0000 Subject: fix: Fix search input escape listener to only work when the input is in focus --- apps/web/components/dashboard/search/SearchInput.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'apps/web/components/dashboard/search') diff --git a/apps/web/components/dashboard/search/SearchInput.tsx b/apps/web/components/dashboard/search/SearchInput.tsx index 0f752fde..a7caf44e 100644 --- a/apps/web/components/dashboard/search/SearchInput.tsx +++ b/apps/web/components/dashboard/search/SearchInput.tsx @@ -20,7 +20,11 @@ function useFocusSearchOnKeyPress( const length = inputRef.current.value.length; inputRef.current.setSelectionRange(length, length); } - if (e.code === "Escape") { + if ( + e.code === "Escape" && + e.target == inputRef.current && + inputRef.current.value !== "" + ) { e.preventDefault(); inputRef.current.blur(); inputRef.current.value = ""; -- cgit v1.2.3-70-g09d2