From ec03f6d693fb08e9a89e2448937c8a343e787070 Mon Sep 17 00:00:00 2001 From: Sagar naik Date: Mon, 25 Nov 2024 19:37:24 +0530 Subject: [PATCH] fix: global search enter listener (#1797) --- .../Analytics/GlobalSearch/GlobalSearchBar.res | 12 ------------ .../Analytics/GlobalSearch/GlobalSearchBarHelper.res | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/screens/Analytics/GlobalSearch/GlobalSearchBar.res b/src/screens/Analytics/GlobalSearch/GlobalSearchBar.res index 6d52ae644..493533cac 100644 --- a/src/screens/Analytics/GlobalSearch/GlobalSearchBar.res +++ b/src/screens/Analytics/GlobalSearch/GlobalSearchBar.res @@ -38,18 +38,6 @@ let make = () => { } } - React.useEffect(() => { - let onKeyPress = event => { - let keyPressed = event->ReactEvent.Keyboard.key - - if keyPressed == "Enter" { - selectedOption->redirectOnSelect - } - } - Window.addEventListener("keydown", onKeyPress) - Some(() => Window.removeEventListener("keydown", onKeyPress)) - }, []) - let getCategoryOptions = async () => { setState(_ => Loading) try { diff --git a/src/screens/Analytics/GlobalSearch/GlobalSearchBarHelper.res b/src/screens/Analytics/GlobalSearch/GlobalSearchBarHelper.res index f71f585a7..e907662c0 100644 --- a/src/screens/Analytics/GlobalSearch/GlobalSearchBarHelper.res +++ b/src/screens/Analytics/GlobalSearch/GlobalSearchBarHelper.res @@ -398,7 +398,7 @@ module ModalSearchBox = { | Some(val) => setSelectedOption(_ => val) | _ => () } - } else if e->keyCode == 13 { + } else if e->keyCode == 13 && localSearchText->isNonEmptyString { selectedOption->redirectOnSelect }