Commit 9d6d70d2
| SHA | 9d6d70d21f86942732870c5aca536d43c1aa1c97 |
|---|---|
| Author | Mohamed Bassem <me at mbassem dot com> |
| Author Date | 2024-10-27 08:37 +0000 |
| Committer | Mohamed Bassem <me at mbassem dot com> |
| Commit Date | 2024-10-27 08:37 +0000 |
| Parent(s) | c0b069114416 (diff) |
| Tree | 39eb957687e8 |
fix: Fix search input escape listener to only work when the input is in focus
| File | + | - | Graph | |
|---|---|---|---|---|
| M | apps/web/components/dashboard/search/SearchInput.tsx | +5 | -1 |
|
1 file(s) changed, 5 insertions(+), 1 deletions(-)
apps/web/components/dashboard/search/SearchInput.tsx
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 = "";