mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-21 23:34:31 +00:00
[BugFix] Properly trigger onClose hook in dialogService (#2655)
This commit is contained in:
@@ -280,5 +280,22 @@ test.describe('Topbar commands', () => {
|
||||
await comfyPage.confirmDialog.click('confirm')
|
||||
expect(await comfyPage.page.evaluate(() => window['value'])).toBe(true)
|
||||
})
|
||||
|
||||
test('Should allow dismissing a dialog', async ({ comfyPage }) => {
|
||||
await comfyPage.page.evaluate(() => {
|
||||
window['value'] = 'foo'
|
||||
window['app'].extensionManager.dialog
|
||||
.confirm({
|
||||
title: 'Test Confirm',
|
||||
message: 'Test Confirm Message'
|
||||
})
|
||||
.then((value: boolean) => {
|
||||
window['value'] = value
|
||||
})
|
||||
})
|
||||
|
||||
await comfyPage.confirmDialog.click('reject')
|
||||
expect(await comfyPage.page.evaluate(() => window['value'])).toBeNull()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -43,18 +43,13 @@ export const useDialogStore = defineStore('dialog', () => {
|
||||
}
|
||||
|
||||
function closeDialog(options?: { key: string }) {
|
||||
if (!options) {
|
||||
dialogStack.value.pop()
|
||||
return
|
||||
}
|
||||
const targetDialog = options
|
||||
? dialogStack.value.find((d) => d.key === options.key)
|
||||
: dialogStack.value[0]
|
||||
if (!targetDialog) return
|
||||
|
||||
const dialogKey = options.key
|
||||
|
||||
const index = dialogStack.value.findIndex((d) => d.key === dialogKey)
|
||||
if (index === -1) {
|
||||
return
|
||||
}
|
||||
dialogStack.value.splice(index, 1)
|
||||
targetDialog.dialogComponentProps?.onClose?.()
|
||||
dialogStack.value.splice(dialogStack.value.indexOf(targetDialog), 1)
|
||||
}
|
||||
|
||||
function createDialog(options: {
|
||||
@@ -93,7 +88,6 @@ export const useDialogStore = defineStore('dialog', () => {
|
||||
dialog.dialogComponentProps.maximized = false
|
||||
},
|
||||
onAfterHide: () => {
|
||||
options.dialogComponentProps?.onClose?.()
|
||||
closeDialog(dialog)
|
||||
},
|
||||
pt: {
|
||||
|
||||
Reference in New Issue
Block a user