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;