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.tsxindex 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) returnevent.preventDefault()event.stopPropagation()+ if (blocked) returndismiss('escape')return}diff --git a/packages/frontend-components/src/edit/__tests__/DialogShell.test.tsx b/packages/frontend-components/src/edit/__tests__/DialogShell.test.tsxindex 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' })