mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 11:11:53 +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')
|
await comfyPage.confirmDialog.click('confirm')
|
||||||
expect(await comfyPage.page.evaluate(() => window['value'])).toBe(true)
|
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 }) {
|
function closeDialog(options?: { key: string }) {
|
||||||
if (!options) {
|
const targetDialog = options
|
||||||
dialogStack.value.pop()
|
? dialogStack.value.find((d) => d.key === options.key)
|
||||||
return
|
: dialogStack.value[0]
|
||||||
}
|
if (!targetDialog) return
|
||||||
|
|
||||||
const dialogKey = options.key
|
targetDialog.dialogComponentProps?.onClose?.()
|
||||||
|
dialogStack.value.splice(dialogStack.value.indexOf(targetDialog), 1)
|
||||||
const index = dialogStack.value.findIndex((d) => d.key === dialogKey)
|
|
||||||
if (index === -1) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dialogStack.value.splice(index, 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createDialog(options: {
|
function createDialog(options: {
|
||||||
@@ -93,7 +88,6 @@ export const useDialogStore = defineStore('dialog', () => {
|
|||||||
dialog.dialogComponentProps.maximized = false
|
dialog.dialogComponentProps.maximized = false
|
||||||
},
|
},
|
||||||
onAfterHide: () => {
|
onAfterHide: () => {
|
||||||
options.dialogComponentProps?.onClose?.()
|
|
||||||
closeDialog(dialog)
|
closeDialog(dialog)
|
||||||
},
|
},
|
||||||
pt: {
|
pt: {
|
||||||
|
|||||||
Reference in New Issue
Block a user