Skip to content

Commit 1797b6e

Browse files
authored
fix: for react-testing-library to find dialog by findByRole with labe… (#290)
* fix: for react-testing-library to find dialog by findByRole with labelName as priority in rules on top of findByLabelText * test snapshot updated * removed unnecessary aria-labelledBy
1 parent 061bd82 commit 1797b6e

File tree

3 files changed

+2
-3
lines changed

3 files changed

+2
-3
lines changed

src/Dialog/Content/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
142142
<div
143143
key="dialog-element"
144144
role="dialog"
145+
aria-labelledby={title ? ariaId : null}
145146
aria-modal="true"
146147
ref={motionRef}
147148
style={{ ...motionStyle, ...style, ...contentStyle }}

src/Dialog/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export default function Dialog(props: IDialogChildProps) {
2929
scrollLocker,
3030

3131
// Wrapper
32-
title,
3332
wrapStyle,
3433
wrapClassName,
3534
wrapProps,
@@ -182,7 +181,6 @@ export default function Dialog(props: IDialogChildProps) {
182181
className={classNames(`${prefixCls}-wrap`, wrapClassName)}
183182
ref={wrapperRef}
184183
onClick={onWrapperClick}
185-
aria-labelledby={title ? ariaId : null}
186184
style={{ zIndex, ...wrapStyle, display: !animatedVisible ? 'none' : null }}
187185
{...wrapProps}
188186
>

tests/__snapshots__/index.spec.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ exports[`dialog should render correct 1`] = `
5757
class="rc-dialog-mask"
5858
/>
5959
<div
60-
aria-labelledby="test-id"
6160
class="rc-dialog-wrap"
6261
tabindex="-1"
6362
>
6463
<div
64+
aria-labelledby="test-id"
6565
aria-modal="true"
6666
class="rc-dialog"
6767
role="dialog"

0 commit comments

Comments
 (0)