File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ import ReactModal from 'react-modal';
9999 shouldReturnFocusAfterClose= {true }
100100 /*
101101 String indicating the role of the modal, allowing the 'dialog' role to be applied if desired.
102+ This attribute is `dialog` by default.
102103 */
103104 role= " dialog"
104105 /*
Original file line number Diff line number Diff line change @@ -117,6 +117,19 @@ export default () => {
117117 contentAttribute ( modal , "role" ) . should . be . eql ( "dialog" ) ;
118118 } ) ;
119119
120+ // eslint-disable-next-line max-len
121+ it ( "renders the modal content with the default aria role when not provided" , ( ) => {
122+ const child = "I am a child of Modal, and he has sent me here..." ;
123+ const modal = renderModal ( { isOpen : true } , child ) ;
124+ contentAttribute ( modal , "role" ) . should . be . eql ( "dialog" ) ;
125+ } ) ;
126+
127+ it ( "does not render the aria role when provided role with null" , ( ) => {
128+ const child = "I am a child of Modal, and he has sent me here..." ;
129+ const modal = renderModal ( { isOpen : true , role : null } , child ) ;
130+ should ( contentAttribute ( modal , "role" ) ) . be . eql ( null ) ;
131+ } ) ;
132+
120133 it ( "sets aria-label based on the contentLabel prop" , ( ) => {
121134 const child = "I am a child of Modal, and he has sent me here..." ;
122135 const modal = renderModal (
Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ class Modal extends Component {
7373 isOpen : false ,
7474 portalClassName,
7575 bodyOpenClassName,
76+ role : "dialog" ,
7677 ariaHideApp : true ,
7778 closeTimeoutMS : 0 ,
7879 shouldFocusAfterRender : true ,
You can’t perform that action at this time.
0 commit comments