Skip to content

Commit

Permalink
fix: Fix search input escape listener to only work when the input is …
Browse files Browse the repository at this point in the history
…in focus
  • Loading branch information
MohamedBassem committed Oct 27, 2024
1 parent c0b0691 commit 9d6d70d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/web/components/dashboard/search/SearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down

0 comments on commit 9d6d70d

Please sign in to comment.