Skip to content

Commit d21669a

Browse files
committed
Add delay before keyboard/click events to ensure event listeners are attached
1 parent 4565662 commit d21669a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/components/Modal.stories.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ export const EscapeKeyCloses: Story = {
205205
const modal = document.querySelector('[role="dialog"]');
206206
await expect(modal).toBeInTheDocument();
207207

208+
// Wait for modal to be fully mounted and event listeners attached
209+
await new Promise((resolve) => setTimeout(resolve, 100));
210+
208211
// Press Escape key
209212
await userEvent.keyboard("{Escape}");
210213

@@ -243,6 +246,9 @@ export const OverlayClickCloses: Story = {
243246
const modal = document.querySelector('[role="dialog"]');
244247
await expect(modal).toBeInTheDocument();
245248

249+
// Wait for modal to be fully mounted and event listeners attached
250+
await new Promise((resolve) => setTimeout(resolve, 100));
251+
246252
// Click on overlay (role="presentation")
247253
const overlay = document.querySelector('[role="presentation"]');
248254
await expect(overlay).toBeInTheDocument();

0 commit comments

Comments
 (0)