From 0955b8b810bf8481cddecd319d6179c8b9c5e952 Mon Sep 17 00:00:00 2001 From: yyh <92089059+lyzno1@users.noreply.github.com> Date: Tue, 8 Sep 2026 09:38:11 +0000 Subject: [PATCH] fix(web): reset goto anything search after dialog closes (#41976) --- .../goto-anything/__tests__/index.spec.tsx | 2 +- web/app/components/goto-anything/index.tsx | 23 ++++++------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/web/app/components/goto-anything/__tests__/index.spec.tsx b/web/app/components/goto-anything/__tests__/index.spec.tsx index 4fb6e3825f4..4cc4b3a0751 100644 --- a/web/app/components/goto-anything/__tests__/index.spec.tsx +++ b/web/app/components/goto-anything/__tests__/index.spec.tsx @@ -388,7 +388,7 @@ describe('GotoAnything', () => { expect(input).toHaveFocus() }) - it('should reset search query when modal opens', async () => { + it('should reopen with an empty search after the modal finishes closing', async () => { const user = userEvent.setup() renderGotoAnything() diff --git a/web/app/components/goto-anything/index.tsx b/web/app/components/goto-anything/index.tsx index 336f0d8e99f..b0a23c860e2 100644 --- a/web/app/components/goto-anything/index.tsx +++ b/web/app/components/goto-anything/index.tsx @@ -226,7 +226,7 @@ function chunkArray(items: readonly T[], size: number): T[][] { return rows } -function GotoAnythingDialog() { +export function GotoAnything() { const { t } = useTranslation() const pathname = usePathname() const router = useRouter() @@ -379,8 +379,8 @@ function GotoAnythingDialog() { const dedupedResults = dedupeSearchResults(searchResults) const groupedResults = groupSearchResults(dedupedResults) - function resetSearch() { - setSearchQuery('') + function handleDialogOpenChangeComplete(open: boolean) { + if (!open) setSearchQuery('') } useHotkey( @@ -432,13 +432,6 @@ function GotoAnythingDialog() { } } - function handleAutocompleteOpenChange( - nextOpen: boolean, - eventDetails: AutocompleteChangeEventDetails, - ) { - if (!nextOpen && eventDetails.reason === 'escape-key') gotoAnythingDialogHandle.close() - } - function handleAutocompleteValueChange( nextValue: string, eventDetails: AutocompleteChangeEventDetails, @@ -500,7 +493,10 @@ function GotoAnythingDialog() { return ( <> - + ) } - -export function GotoAnything() { - return -}