Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(toast): remove invalid aria-modal from notifications viewport (#3531)

Cindy Zhangd9633cc04204
diff --git a/.changeset/toast-viewport-aria-modal.md b/.changeset/toast-viewport-aria-modal.md
new file mode 100644
index 0000000000..618a49c5a5
--- /dev/null
+++ b/.changeset/toast-viewport-aria-modal.md
@@ -0,0 +1,6 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Toast: remove the invalid `aria-modal` attribute from the notifications viewport. `aria-modal` is only valid on `role="dialog"` / `alertdialog`, so declaring it on the `role="region"` viewport was flagged by axe (`aria-allowed-attr`). Because the viewport renders on every page, this surfaced the violation across the whole app (#3343).
+@cixzhang
diff --git a/packages/core/src/Toast/ToastViewport.test.tsx b/packages/core/src/Toast/ToastViewport.test.tsx
index a65f233900..9a8d5966a2 100644
--- a/packages/core/src/Toast/ToastViewport.test.tsx
+++ b/packages/core/src/Toast/ToastViewport.test.tsx
@@ -202,3 +202,13 @@ describe('Toast blur timer pause', () => {
}
});
});
+
+describe('ToastViewport region ARIA', () => {
+ it('exposes the notifications region without a prohibited aria-modal', () => {
+ renderViewport(<ShowToastButton />);
+ const region = screen.getByRole('region', {name: 'Notifications'});
+ // aria-modal is only valid on role="dialog"/"alertdialog"; a region must
+ // not declare it (axe: aria-allowed-attr).
+ expect(region).not.toHaveAttribute('aria-modal');
+ });
+});
diff --git a/packages/core/src/Toast/ToastViewport.tsx b/packages/core/src/Toast/ToastViewport.tsx
index 6ddb25a015..3864dcc9cf 100644
--- a/packages/core/src/Toast/ToastViewport.tsx
+++ b/packages/core/src/Toast/ToastViewport.tsx
@@ -136,8 +136,9 @@ export function ToastViewport({
if (!container) {
return null;
}
- const candidates =
- container.querySelectorAll<HTMLElement>(INTERACTIVE_SELECTORS);
+ const candidates = container.querySelectorAll<HTMLElement>(
+ INTERACTIVE_SELECTORS,
+ );
for (const candidate of candidates) {
if (
candidate.getAttribute('tabindex') === '-1' ||
@@ -351,7 +352,6 @@ export function ToastViewport({
ref={viewportRef}
role="region"
aria-label="Notifications"
- aria-modal={false}
tabIndex={-1}
// popover="manual" promotes to the top layer (above dialogs).
// Omitted inside dialogs where the viewport is already in a top layer.