Unverified Commit 14ccb667 authored by Tor Raswill's avatar Tor Raswill Committed by GitHub
Browse files

#5084 sets aria-labelledby on correct element (#5105)



fixes #5084. Adds test to check that aria-labelledby is set on the Modal element.
Co-authored-by: default avatarTor Raswill <tor.raswill@dqc.se>
parent 369cd83f
......@@ -167,6 +167,8 @@ const propTypes = {
* @private
*/
container: PropTypes.any,
'aria-labelledby': PropTypes.any,
};
const defaultProps = {
......@@ -317,6 +319,7 @@ class Modal extends React.Component {
dialogClassName,
children,
dialogAs: Dialog,
'aria-labelledby': ariaLabelledby,
/* BaseModal props */
show,
......@@ -382,6 +385,7 @@ class Modal extends React.Component {
onEnter: this.handleEnter,
onEntering: this.handleEntering,
onExited: this.handleExited,
'aria-labelledby': ariaLabelledby,
}}
>
<Dialog
......
......@@ -224,4 +224,18 @@ describe('<Modal>', () => {
expect(onHideSpy).to.not.have.been.called;
});
it('Should set aria-labelledby to the role="dialog" element if aria-labelledby set', () => {
const noOp = () => {};
const wrapper = mount(
<Modal show onHide={noOp} aria-labelledby="modal-title">
<Modal.Header closeButton>
<Modal.Title id="modal-title">Modal heading</Modal.Title>
</Modal.Header>
</Modal>,
);
wrapper.assertSingle(
'div.modal.show[role="dialog"][aria-labelledby="modal-title"]',
);
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment