Skip to content

Commit cca1d77

Browse files
committed
fix(Dialog): panel type * 3
1 parent 4e6dbbb commit cca1d77

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/components/overlays/Dialog/Dialog.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export const Dialog = forwardRef(function Dialog(
154154
}
155155

156156
return (
157-
<FocusScope contain restoreFocus>
157+
<FocusScope contain restoreFocus autoFocus>
158158
{content}
159159
</FocusScope>
160160
);
@@ -250,6 +250,7 @@ const DialogContent = forwardRef(function DialogContent(
250250
styles={styles}
251251
as="section"
252252
{...dialogProps}
253+
tabIndex={undefined}
253254
mods={{ dismissable: isDismissable }}
254255
style={{ '--dialog-size': `${sizePxMap[size] || 288}px` }}
255256
data-type={type}
@@ -262,6 +263,7 @@ const DialogContent = forwardRef(function DialogContent(
262263
<Button
263264
qa="ModalCloseButton"
264265
type="neutral"
266+
tabIndex="-1"
265267
styles={CLOSE_BUTTON_STYLES}
266268
icon={closeIcon || <CloseIcon />}
267269
label={formatMessage('dismiss')}

src/components/overlays/Dialog/stories/Dialog.stories.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,21 +198,20 @@ CloseOnEsc.play = async (context) => {
198198

199199
await userEvent.click(trigger);
200200

201+
await timeout(500);
202+
201203
const dialog = await findByRole('dialog');
202204

203205
await expect(dialog).toBeInTheDocument();
204206
await expect(dialog.contains(document.activeElement)).toBe(true);
205207

206-
await timeout(500);
207-
208208
await userEvent.keyboard('{Escape}');
209209

210210
await timeout(500);
211211

212212
await expect(dialog).not.toBeInTheDocument();
213213

214-
// @TODO: fix this
215-
// await waitFor(() => expect(document.activeElement).toBe(trigger));
214+
await waitFor(() => expect(document.activeElement).toBe(trigger));
216215
};
217216

218217
export const CloseOnEscCloseBehaviorHide: typeof Template = Template.bind({});

0 commit comments

Comments
 (0)