File tree 3 files changed +15
-0
lines changed
3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ import ReactModal from 'react-modal';
99
99
shouldReturnFocusAfterClose= {true }
100
100
/*
101
101
String indicating the role of the modal, allowing the 'dialog' role to be applied if desired.
102
+ This attribute is `dialog` by default.
102
103
*/
103
104
role= " dialog"
104
105
/*
Original file line number Diff line number Diff line change @@ -117,6 +117,19 @@ export default () => {
117
117
contentAttribute ( modal , "role" ) . should . be . eql ( "dialog" ) ;
118
118
} ) ;
119
119
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
+
120
133
it ( "sets aria-label based on the contentLabel prop" , ( ) => {
121
134
const child = "I am a child of Modal, and he has sent me here..." ;
122
135
const modal = renderModal (
Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ class Modal extends Component {
73
73
isOpen : false ,
74
74
portalClassName,
75
75
bodyOpenClassName,
76
+ role : "dialog" ,
76
77
ariaHideApp : true ,
77
78
closeTimeoutMS : 0 ,
78
79
shouldFocusAfterRender : true ,
You can’t perform that action at this time.
0 commit comments