Skip to content

Commit b87c209

Browse files
committed
fix(SlidingPane): add ARIA attributes for screen reader support
1 parent b870a05 commit b87c209

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/components/SlidingPane/SlidingPane.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { useId } from 'react';
22
import classNames from 'classnames';
33
import ExitIcon from '@moda/icons/exit-16';
44
import { FocusOn } from 'react-focus-on';
@@ -24,6 +24,8 @@ export const SlidingPane: React.FC<SlidingPaneProps> = ({
2424
autoFocus = true,
2525
...rest
2626
}) => {
27+
const titleId = useId();
28+
2729
return (
2830
<>
2931
<div
@@ -40,6 +42,9 @@ export const SlidingPane: React.FC<SlidingPaneProps> = ({
4042
onEscapeKey={onClose}
4143
>
4244
<div
45+
role='dialog'
46+
aria-modal='true'
47+
aria-labelledby={titleId}
4348
className={classNames('SlidingPane', className, {
4449
'SlidingPane--active': visible
4550
})}
@@ -51,7 +56,7 @@ export const SlidingPane: React.FC<SlidingPaneProps> = ({
5156
direction='horizontal'
5257
className='SlidingPane__top'
5358
>
54-
<Text treatment='h5' family='serif'>
59+
<Text id={titleId} treatment='h5' family='serif'>
5560
{title}
5661
</Text>
5762
<Clickable className='SlidingPane__close' aria-label='Close' onClick={onClose}>

0 commit comments

Comments
 (0)