Skip to content

Commit 8347e4f

Browse files
authored
Fixes accessibility issue created by incorrect dialog role (#285)
* Fixes roles * Adds aria-modal attribute * Updates snapshot * Adds aria-modal to snapshot * Moves aria-modal
1 parent b37ffd0 commit 8347e4f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/Dialog/Content/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ export type ContentProps = {
1414
onVisibleChanged: (visible: boolean) => void;
1515
onMouseDown: React.MouseEventHandler;
1616
onMouseUp: React.MouseEventHandler;
17-
} & IDialogChildProps
17+
} & IDialogChildProps;
1818

1919
export type ContentRef = {
2020
focus: () => void;
2121
changeActive: (next: boolean) => void;
22-
}
22+
};
2323

2424
const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
2525
const {
@@ -141,7 +141,8 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
141141
{({ className: motionClassName, style: motionStyle }, motionRef) => (
142142
<div
143143
key="dialog-element"
144-
role="document"
144+
role="dialog"
145+
aria-modal="true"
145146
ref={motionRef}
146147
style={{ ...motionStyle, ...style, ...contentStyle }}
147148
className={classNames(prefixCls, className, motionClassName)}

src/Dialog/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ export default function Dialog(props: IDialogChildProps) {
182182
className={classNames(`${prefixCls}-wrap`, wrapClassName)}
183183
ref={wrapperRef}
184184
onClick={onWrapperClick}
185-
role="dialog"
186185
aria-labelledby={title ? ariaId : null}
187186
style={{ zIndex, ...wrapStyle, display: !animatedVisible ? 'none' : null }}
188187
{...wrapProps}

tests/__snapshots__/index.spec.tsx.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ exports[`dialog add rootClassName should render correct 1`] = `
99
/>
1010
<div
1111
class="rc-dialog-wrap"
12-
role="dialog"
1312
style="font-size: 10px;"
1413
tabindex="-1"
1514
>
1615
<div
16+
aria-modal="true"
1717
class="rc-dialog"
18-
role="document"
18+
role="dialog"
1919
style="width: 600px; height: 903px;"
2020
>
2121
<div
@@ -59,12 +59,12 @@ exports[`dialog should render correct 1`] = `
5959
<div
6060
aria-labelledby="test-id"
6161
class="rc-dialog-wrap"
62-
role="dialog"
6362
tabindex="-1"
6463
>
6564
<div
65+
aria-modal="true"
6666
class="rc-dialog"
67-
role="document"
67+
role="dialog"
6868
>
6969
<div
7070
aria-hidden="true"

0 commit comments

Comments
 (0)