File tree 4 files changed +28
-8
lines changed
4 files changed +28
-8
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ class Collapse extends React.Component {
48
48
< Transition
49
49
ref = 'transition'
50
50
{ ...this . props }
51
- aria-expanded = { this . props . in }
51
+ aria-expanded = { this . props . role ? this . props . in : null }
52
52
className = { this . _dimension ( ) === 'width' ? 'width' : '' }
53
53
exitedClassName = 'collapse'
54
54
exitingClassName = 'collapsing'
@@ -184,7 +184,12 @@ Collapse.propTypes = {
184
184
* should animate in its specified dimension. Called with the current
185
185
* dimension prop value and the DOM node.
186
186
*/
187
- getDimensionValue : React . PropTypes . func
187
+ getDimensionValue : React . PropTypes . func ,
188
+
189
+ /**
190
+ * ARIA role of collapsible element
191
+ */
192
+ role : React . PropTypes . string
188
193
} ;
189
194
190
195
Collapse . defaultProps = {
Original file line number Diff line number Diff line change @@ -79,8 +79,7 @@ const Panel = React.createClass({
79
79
< div
80
80
className = { collapseClass }
81
81
id = { this . props . id }
82
- ref = 'panel'
83
- aria-expanded = { this . isExpanded ( ) } >
82
+ ref = 'panel' >
84
83
{ this . renderBody ( ) }
85
84
86
85
</ div >
Original file line number Diff line number Diff line change @@ -213,4 +213,24 @@ describe('Collapse', function () {
213
213
assert . equal ( instance . collapse . _dimension ( ) , 'whatevs' ) ;
214
214
} ) ;
215
215
} ) ;
216
+
217
+ describe ( 'with a role' , function ( ) {
218
+ beforeEach ( function ( ) {
219
+ instance = ReactTestUtils . renderIntoDocument (
220
+ < Component role = "note" > Panel content</ Component >
221
+ ) ;
222
+ } ) ;
223
+
224
+ it ( 'sets aria-expanded true when expanded' , function ( ) {
225
+ let node = React . findDOMNode ( instance ) ;
226
+ instance . setProps ( { in : true } ) ;
227
+ assert . equal ( node . getAttribute ( 'aria-expanded' ) , 'true' ) ;
228
+ } ) ;
229
+
230
+ it ( 'sets aria-expanded false when collapsed' , function ( ) {
231
+ let node = React . findDOMNode ( instance ) ;
232
+ instance . setProps ( { in : false } ) ;
233
+ assert . equal ( node . getAttribute ( 'aria-expanded' ) , 'false' ) ;
234
+ } ) ;
235
+ } ) ;
216
236
} ) ;
Original file line number Diff line number Diff line change @@ -191,19 +191,15 @@ describe('Panel', function () {
191
191
let instance = ReactTestUtils . renderIntoDocument (
192
192
< Panel collapsible = { true } expanded = { true } header = "Heading" > Panel content</ Panel >
193
193
) ;
194
- let collapse = React . findDOMNode ( instance ) . querySelector ( '.panel-collapse' ) ;
195
194
let anchor = React . findDOMNode ( instance ) . querySelector ( '.panel-title a' ) ;
196
- assert . equal ( collapse . getAttribute ( 'aria-expanded' ) , 'true' ) ;
197
195
assert . equal ( anchor . getAttribute ( 'aria-expanded' ) , 'true' ) ;
198
196
} ) ;
199
197
200
198
it ( 'Should be aria-expanded=false' , function ( ) {
201
199
let instance = ReactTestUtils . renderIntoDocument (
202
200
< Panel collapsible = { true } expanded = { false } header = "Heading" > Panel content</ Panel >
203
201
) ;
204
- let collapse = React . findDOMNode ( instance ) . querySelector ( '.panel-collapse' ) ;
205
202
let anchor = React . findDOMNode ( instance ) . querySelector ( '.panel-title a' ) ;
206
- assert . equal ( collapse . getAttribute ( 'aria-expanded' ) , 'false' ) ;
207
203
assert . equal ( anchor . getAttribute ( 'aria-expanded' ) , 'false' ) ;
208
204
} ) ;
209
205
You can’t perform that action at this time.
0 commit comments