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 (
<>
-