Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

fix: Fix search input escape listener to only work when the input is in focus

Mohamed Bassem9d6d70d21f86
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 = "";