Skip to content

Commit f385e68

Browse files
jzempelze-flo
andauthored
chore(next): updates from main (#1796)
* fix(Notifications): improve screen-reader support (#1790) * chore(changelog): add v8.76.1 --------- Co-authored-by: Florent <[email protected]>
1 parent a745bde commit f385e68

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

docs/changelogs/v8.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
1010
_Note: Gaps between patch versions are faulty, broken or test releases._
1111

12+
## v8.76.1 (2024-04-18)
13+
14+
#### :bug: Bug Fix
15+
* `notifications`
16+
* [#1790](https://github.com/zendeskgarden/react-components/pull/1790) fix(Notifications): improve screen-reader support ([@ze-flo](https://github.com/ze-flo))
17+
1218
## v8.76.0 (2024-04-12)
1319

1420
#### :rocket: New Feature

packages/notifications/src/elements/Notification.spec.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ describe('Notification', () => {
2020
it('has a default role attribute', () => {
2121
const { container } = render(<Notification type="success" />);
2222

23-
expect(container.firstChild).toHaveAttribute('role', 'status');
23+
expect(container.firstChild).toHaveAttribute('role', 'alert');
2424
});
2525

2626
it('can have its role attribute modified', () => {
27-
const { container } = render(<Notification type="error" role="alert" />);
27+
// eslint-disable-next-line jsx-a11y/prefer-tag-over-role
28+
const { container } = render(<Notification type="error" role="status" />);
2829

29-
expect(container.firstChild).toHaveAttribute('role', 'alert');
30+
expect(container.firstChild).toHaveAttribute('role', 'status');
3031
});
3132

3233
it('can have its role attribute removed', () => {

packages/notifications/src/elements/Notification.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,19 @@ import { Paragraph } from './content/Paragraph';
1616
import { Close } from './content/Close';
1717

1818
export const NotificationComponent = forwardRef<HTMLDivElement, INotificationProps>(
19-
({ role, ...props }, ref) => {
20-
const Icon = props.type ? validationIcons[props.type] : InfoStrokeIcon;
21-
const hue = props.type && validationHues[props.type];
19+
({ children, type, ...props }, ref) => {
20+
const Icon = type ? validationIcons[type] : InfoStrokeIcon;
21+
const hue = type && validationHues[type];
2222

2323
return (
24-
<StyledNotification
25-
ref={ref}
26-
type={props.type}
27-
isFloating
28-
{...props}
29-
role={role === undefined ? 'status' : role}
30-
>
31-
{props.type && (
24+
<StyledNotification ref={ref} type={type} isFloating role="alert" {...props}>
25+
{type && (
3226
<StyledIcon $hue={hue}>
3327
<Icon />
3428
</StyledIcon>
3529
)}
3630

37-
{props.children}
31+
{children}
3832
</StyledNotification>
3933
);
4034
}

0 commit comments

Comments
 (0)