Fix: Escape closes Settings dialog if login dialog open (#4364)

This commit is contained in:
Sidharth
2025-07-24 11:11:26 +05:30
committed by GitHub
parent 309a5b8c9a
commit b240c090aa
3 changed files with 97 additions and 6 deletions

View File

@@ -172,4 +172,58 @@ describe('dialogStore', () => {
expect(store.dialogStack[0].title).toBe('Original Title')
})
})
describe('ESC key behavior with multiple dialogs', () => {
it('should only allow the active dialog to close with ESC key', () => {
const store = useDialogStore()
// Create dialogs with different priorities
store.showDialog({
key: 'dialog-1',
component: MockComponent,
priority: 1
})
store.showDialog({
key: 'dialog-2',
component: MockComponent,
priority: 2
})
store.showDialog({
key: 'dialog-3',
component: MockComponent,
priority: 3
})
// Only the active dialog should be closable with ESC
const activeDialog = store.dialogStack.find(
(d) => d.key === store.activeKey
)
const inactiveDialogs = store.dialogStack.filter(
(d) => d.key !== store.activeKey
)
expect(activeDialog?.dialogComponentProps.closeOnEscape).toBe(true)
inactiveDialogs.forEach((dialog) => {
expect(dialog.dialogComponentProps.closeOnEscape).toBe(false)
})
// Close the active dialog
store.closeDialog({ key: store.activeKey! })
// The new active dialog should now be closable with ESC
const newActiveDialog = store.dialogStack.find(
(d) => d.key === store.activeKey
)
const newInactiveDialogs = store.dialogStack.filter(
(d) => d.key !== store.activeKey
)
expect(newActiveDialog?.dialogComponentProps.closeOnEscape).toBe(true)
newInactiveDialogs.forEach((dialog) => {
expect(dialog.dialogComponentProps.closeOnEscape).toBe(false)
})
})
})
})