mirror of
https://github.com/langgenius/dify.git
synced 2026-09-09 13:52:42 +08:00
fix(web): reset goto anything search after dialog closes (#41976)
This commit is contained in:
parent
c9e0118ae9
commit
0955b8b810
@ -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(<GotoAnything />)
|
||||
|
||||
|
||||
@ -226,7 +226,7 @@ function chunkArray<T>(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 (
|
||||
<>
|
||||
<SlashCommandProvider />
|
||||
<Dialog handle={gotoAnythingDialogHandle} onOpenChange={resetSearch}>
|
||||
<Dialog
|
||||
handle={gotoAnythingDialogHandle}
|
||||
onOpenChangeComplete={handleDialogOpenChangeComplete}
|
||||
>
|
||||
<DialogPortal>
|
||||
<DialogBackdrop />
|
||||
<DialogPopup
|
||||
@ -522,7 +518,6 @@ function GotoAnythingDialog() {
|
||||
items={visibleOptions}
|
||||
value={searchQuery}
|
||||
onValueChange={handleAutocompleteValueChange}
|
||||
onOpenChange={handleAutocompleteOpenChange}
|
||||
itemToStringValue={optionToInputValue}
|
||||
filter={null}
|
||||
grid={isCommandsMode}
|
||||
@ -709,7 +704,3 @@ function GotoAnythingDialog() {
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export function GotoAnything() {
|
||||
return <GotoAnythingDialog />
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user