From c51ab6ec3722338ad619f079ab235a2435be7f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=9E=E6=B3=95=E6=93=8D=E4=BD=9C?= Date: Fri, 28 Nov 2025 14:29:15 +0800 Subject: [PATCH] fix: the consistency of the go-to-anything interaction (#28857) --- web/app/components/goto-anything/index.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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}