diff --git a/web/app/components/goto-anything/index.tsx b/web/app/components/goto-anything/index.tsx index 1f153190f2..5cdf970725 100644 --- a/web/app/components/goto-anything/index.tsx +++ b/web/app/components/goto-anything/index.tsx @@ -187,6 +187,19 @@ const GotoAnything: FC = ({ }, {} as { [key: string]: SearchResult[] }), [searchResults]) + useEffect(() => { + if (isCommandsMode) + return + + if (!searchResults.length) + return + + const currentValueExists = searchResults.some(result => `${result.type}-${result.id}` === cmdVal) + + if (!currentValueExists) + setCmdVal(`${searchResults[0].type}-${searchResults[0].id}`) + }, [isCommandsMode, searchResults, cmdVal]) + const emptyResult = useMemo(() => { if (searchResults.length || !searchQuery.trim() || isLoading || isCommandsMode) return null @@ -386,7 +399,7 @@ const GotoAnything: FC = ({ handleNavigate(result)} > {result.icon}