Skip to content

Commit bb84fa6

Browse files
fix: Add group role to element referenced by the alert focus ref (#3705)
1 parent 5730732 commit bb84fa6

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/alert/__tests__/alert.test.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ describe('Alert Component', () => {
160160
await expect(container).toValidateA11y();
161161
});
162162

163+
describe('a11y', () => {
164+
it('has role group on the element referenced by the focus ref', () => {
165+
let ref: AlertProps.Ref | null = null;
166+
render(<Alert header="Important" ref={element => (ref = element)} />);
167+
ref!.focus();
168+
expect(document.activeElement).toHaveAttribute('role', 'group');
169+
});
170+
});
171+
163172
describe('analytics', () => {
164173
test(`adds ${DATA_ATTR_ANALYTICS_ALERT} attribute with the alert type`, () => {
165174
const { container } = renderAlert({

src/alert/internal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const InternalAlert = React.forwardRef(
134134
)}
135135
>
136136
<div className={styles['alert-wrapper']}>
137-
<div className={styles['alert-focus-wrapper']} tabIndex={-1} ref={focusRef}>
137+
<div className={styles['alert-focus-wrapper']} tabIndex={-1} ref={focusRef} role="group">
138138
<div className={clsx(styles.icon, styles.text)}>
139139
<InternalIcon name={typeToIcon[type]} size={size} ariaLabel={statusIconAriaLabel} />
140140
</div>

0 commit comments

Comments
 (0)