Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(frontend-components): contain blocked escape events

Josuéb89633141a50
diff --git a/packages/frontend-components/src/edit/DialogShell.tsx b/packages/frontend-components/src/edit/DialogShell.tsx
index 8b45ed72b..e961ee052 100644
--- a/packages/frontend-components/src/edit/DialogShell.tsx
+++ b/packages/frontend-components/src/edit/DialogShell.tsx
@@ -71,9 +71,10 @@ export function DialogShell({
function handleKeyDown(event: KeyboardEvent<HTMLElement>) {
if (event.key === 'Escape') {
- if (!dismissOnEscape || blocked) return
+ if (!dismissOnEscape) return
event.preventDefault()
event.stopPropagation()
+ if (blocked) return
dismiss('escape')
return
}
diff --git a/packages/frontend-components/src/edit/__tests__/DialogShell.test.tsx b/packages/frontend-components/src/edit/__tests__/DialogShell.test.tsx
index 225581677..1957b72fc 100644
--- a/packages/frontend-components/src/edit/__tests__/DialogShell.test.tsx
+++ b/packages/frontend-components/src/edit/__tests__/DialogShell.test.tsx
@@ -82,21 +82,27 @@ describe('DialogShell', () => {
it('supports configured dismissal paths and blocks them while busy by default', async () => {
const onDismiss = vi.fn()
+ const onOutsideKeyDown = vi.fn()
const { rerender } = render(
- <DialogShell busy onDismiss={onDismiss} open title="Saving">
- <button type="button">Continue</button>
- </DialogShell>
+ <div onKeyDown={onOutsideKeyDown}>
+ <DialogShell busy onDismiss={onDismiss} open title="Saving">
+ <button type="button">Continue</button>
+ </DialogShell>
+ </div>
)
const dialog = await screen.findByRole('dialog', { name: 'Saving' })
fireEvent.keyDown(dialog, { key: 'Escape' })
+ expect(onOutsideKeyDown).not.toHaveBeenCalled()
fireEvent.mouseDown(screen.getByTestId('dialog-backdrop'))
await userEvent.setup().click(within(dialog).getByRole('button', { name: 'Close dialog' }))
expect(onDismiss).not.toHaveBeenCalled()
rerender(
- <DialogShell onDismiss={onDismiss} open title="Saving" dismissOnEscape={false}>
- <button type="button">Continue</button>
- </DialogShell>
+ <div onKeyDown={onOutsideKeyDown}>
+ <DialogShell onDismiss={onDismiss} open title="Saving" dismissOnEscape={false}>
+ <button type="button">Continue</button>
+ </DialogShell>
+ </div>
)
const nextDialog = screen.getByRole('dialog', { name: 'Saving' })
fireEvent.keyDown(nextDialog, { key: 'Escape' })