Skip to content

Commit edd16ab

Browse files
committed
fix(dialog): add waitFor to enable focus
1 parent 88a6cd2 commit edd16ab

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/components/dialog/dialog.interactions.stories.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState } from "react";
22
import { StoryObj } from "@storybook/react";
3-
import { userEvent, within, expect } from "@storybook/test";
3+
import { userEvent, within, expect, waitFor } from "@storybook/test";
44

55
import Dialog from ".";
66
import Button from "../button";
@@ -65,11 +65,12 @@ export const FocusManagement: Story = {
6565
await userEvent.click(openButton);
6666

6767
const dialog = await portal.findByRole("dialog");
68+
69+
await waitFor(() => expect(dialog).toBeVisible());
70+
6871
const closeButton = within(dialog).getByRole("button", { name: /close/i });
6972
const firstInput = within(dialog).getByLabelText(/name/i);
7073

71-
await expect(dialog).toBeVisible();
72-
7374
await userEvent.tab();
7475
await userEvent.tab();
7576

0 commit comments

Comments
 (0)