diff --git a/docs/README.md b/docs/README.md index ab274454..bdefa05a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -99,6 +99,7 @@ import ReactModal from 'react-modal'; shouldReturnFocusAfterClose={true} /* String indicating the role of the modal, allowing the 'dialog' role to be applied if desired. + This attribute is `dialog` by default. */ role="dialog" /* diff --git a/specs/Modal.spec.js b/specs/Modal.spec.js index 5fd1b1c2..d008dbf0 100644 --- a/specs/Modal.spec.js +++ b/specs/Modal.spec.js @@ -117,6 +117,19 @@ export default () => { contentAttribute(modal, "role").should.be.eql("dialog"); }); + // eslint-disable-next-line max-len + it("renders the modal content with the default aria role when not provided", () => { + const child = "I am a child of Modal, and he has sent me here..."; + const modal = renderModal({ isOpen: true }, child); + contentAttribute(modal, "role").should.be.eql("dialog"); + }); + + it("does not render the aria role when provided role with null", () => { + const child = "I am a child of Modal, and he has sent me here..."; + const modal = renderModal({ isOpen: true, role: null }, child); + should(contentAttribute(modal, "role")).be.eql(null); + }); + it("sets aria-label based on the contentLabel prop", () => { const child = "I am a child of Modal, and he has sent me here..."; const modal = renderModal( diff --git a/src/components/Modal.js b/src/components/Modal.js index 550cff12..7a9a959b 100644 --- a/src/components/Modal.js +++ b/src/components/Modal.js @@ -73,6 +73,7 @@ class Modal extends Component { isOpen: false, portalClassName, bodyOpenClassName, + role: "dialog", ariaHideApp: true, closeTimeoutMS: 0, shouldFocusAfterRender: true,