Skip to content

Commit 1aec62a

Browse files
authored
fix toast a11y issues (#2595)
1 parent 54f452b commit 1aec62a

File tree

7 files changed

+32
-7
lines changed

7 files changed

+32
-7
lines changed

.changeset/stupid-moons-juggle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@radix-ui/react-toast': patch
3+
---
4+
5+
Fix accessibility issues: aria-hidden on focusable element & not allowed role=status on list item element

cypress/e2e/Toast.cy.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ describe('Toast', () => {
2929
cy.findByText('Add toast').click();
3030
});
3131

32+
it('should have no acessibility issues', () => {
33+
cy.injectAxe();
34+
cy.checkA11y('[aria-label="Notifications (F8)"]');
35+
});
36+
3237
it('should reverse tab order from most recent to least', () => {
3338
cy.findByText('Focusable before viewport').focus();
3439

cypress/support/e2e.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// Import commands.js using ES2015 syntax:
1717
import '@testing-library/cypress/add-commands';
1818
import 'cypress-real-events/support';
19+
import 'cypress-axe';
1920
import './commands';
2021

2122
// Alternatively you can use CommonJS syntax:

cypress/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"target": "es5",
44
"lib": ["es5", "dom"],
5-
"types": ["cypress", "@testing-library/cypress", "cypress-real-events"]
5+
"types": ["cypress", "@testing-library/cypress", "cypress-real-events", "cypress-axe"]
66
},
77
"include": ["**/*.ts"]
88
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
"@types/react": "^19.0.7",
4444
"@types/react-dom": "^19.0.3",
4545
"@types/react-test-renderer": "^19.0.0",
46+
"axe-core": "^4.10.3",
4647
"cypress": "^14.0.0",
48+
"cypress-axe": "1.6.0",
4749
"cypress-real-events": "^1.14.0",
4850
"esbuild": "0.24.2",
4951
"eslint": "^9.18.0",

packages/react/toast/src/toast.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ const FocusProxy = React.forwardRef<FocusProxyElement, ScopedProps<FocusProxyPro
340340

341341
return (
342342
<VisuallyHidden
343-
aria-hidden
344343
tabIndex={0}
345344
{...proxyProps}
346345
ref={forwardedRef}
@@ -555,7 +554,6 @@ const ToastImpl = React.forwardRef<ToastImplElement, ToastImplProps>(
555554
// Toasts are always role=status to avoid stuttering issues with role=alert in SRs.
556555
role="status"
557556
aria-live={type === 'foreground' ? 'assertive' : 'polite'}
558-
aria-atomic
559557
>
560558
{announceTextContent}
561559
</ToastAnnounce>
@@ -572,10 +570,6 @@ const ToastImpl = React.forwardRef<ToastImplElement, ToastImplProps>(
572570
})}
573571
>
574572
<Primitive.li
575-
// Ensure toasts are announced as status list or status when focused
576-
role="status"
577-
aria-live="off"
578-
aria-atomic
579573
tabIndex={0}
580574
data-state={open ? 'open' : 'closed'}
581575
data-swipe-direction={context.swipeDirection}

pnpm-lock.yaml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)