From 6001e69de43a7cacd16067af8b1882048f870422 Mon Sep 17 00:00:00 2001 From: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com> Date: Thu, 17 Jun 2021 12:24:55 +0530 Subject: [PATCH] Highlight the second item in in the omnibar search results (#4611) --- .../editorComponents/GlobalSearch/index.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/client/src/components/editorComponents/GlobalSearch/index.tsx b/app/client/src/components/editorComponents/GlobalSearch/index.tsx index 07577ddb08..ec1c11cc97 100644 --- a/app/client/src/components/editorComponents/GlobalSearch/index.tsx +++ b/app/client/src/components/editorComponents/GlobalSearch/index.tsx @@ -163,13 +163,18 @@ function GlobalSearch() { setQuery(resetSearchQuery); } else { dispatch(setGlobalSearchQuery("")); - if (!query) setActiveItemIndex(1); + if (!query) + recentEntities.length > 1 + ? setActiveItemIndex(2) + : setActiveItemIndex(1); } }, [modalOpen]); useEffect(() => { - setActiveItemIndex(1); - }, [query]); + !query && recentEntities.length > 1 + ? setActiveItemIndex(2) + : setActiveItemIndex(1); + }, [query, recentEntities.length]); const filteredWidgets = useMemo(() => { if (!query) return searchableWidgets;