@@ -60,26 +60,32 @@ const Panel = React.createClass({
60
60
} ,
61
61
62
62
render ( ) {
63
+ let { headerRole, panelRole, ...props } = this . props ;
63
64
return (
64
- < div { ...this . props }
65
+ < div { ...props }
65
66
className = { classNames ( this . props . className , this . getBsClassSet ( ) ) }
66
67
id = { this . props . collapsible ? null : this . props . id } onSelect = { null } >
67
- { this . renderHeading ( ) }
68
- { this . props . collapsible ? this . renderCollapsibleBody ( ) : this . renderBody ( ) }
68
+ { this . renderHeading ( headerRole ) }
69
+ { this . props . collapsible ? this . renderCollapsibleBody ( panelRole ) : this . renderBody ( ) }
69
70
{ this . renderFooter ( ) }
70
71
</ div >
71
72
) ;
72
73
} ,
73
74
74
- renderCollapsibleBody ( ) {
75
- let collapseClass = this . prefixClass ( 'collapse' ) ;
75
+ renderCollapsibleBody ( panelRole ) {
76
+ let props = {
77
+ className : this . prefixClass ( 'collapse' ) ,
78
+ id : this . props . id ,
79
+ ref : 'panel' ,
80
+ 'aria-hidden' : ! this . isExpanded ( )
81
+ } ;
82
+ if ( panelRole ) {
83
+ props . role = panelRole ;
84
+ }
76
85
77
86
return (
78
87
< Collapse in = { this . isExpanded ( ) } >
79
- < div
80
- className = { collapseClass }
81
- id = { this . props . id }
82
- ref = 'panel' >
88
+ < div { ...props } >
83
89
{ this . renderBody ( ) }
84
90
85
91
</ div >
@@ -148,7 +154,7 @@ const Panel = React.createClass({
148
154
return React . isValidElement ( child ) && child . props . fill != null ;
149
155
} ,
150
156
151
- renderHeading ( ) {
157
+ renderHeading ( headerRole ) {
152
158
let header = this . props . header ;
153
159
154
160
if ( ! header ) {
@@ -157,7 +163,7 @@ const Panel = React.createClass({
157
163
158
164
if ( ! React . isValidElement ( header ) || Array . isArray ( header ) ) {
159
165
header = this . props . collapsible ?
160
- this . renderCollapsibleTitle ( header ) : header ;
166
+ this . renderCollapsibleTitle ( header , headerRole ) : header ;
161
167
} else {
162
168
const className = classNames (
163
169
this . prefixClass ( 'title' ) , header . props . className
@@ -166,7 +172,7 @@ const Panel = React.createClass({
166
172
if ( this . props . collapsible ) {
167
173
header = cloneElement ( header , {
168
174
className,
169
- children : this . renderAnchor ( header . props . children )
175
+ children : this . renderAnchor ( header . props . children , headerRole )
170
176
} ) ;
171
177
} else {
172
178
header = cloneElement ( header , { className} ) ;
@@ -180,23 +186,25 @@ const Panel = React.createClass({
180
186
) ;
181
187
} ,
182
188
183
- renderAnchor ( header ) {
189
+ renderAnchor ( header , headerRole ) {
184
190
return (
185
191
< a
186
192
href = { '#' + ( this . props . id || '' ) }
187
193
aria-controls = { this . props . collapsible ? this . props . id : null }
188
194
className = { this . isExpanded ( ) ? null : 'collapsed' }
189
195
aria-expanded = { this . isExpanded ( ) }
190
- onClick = { this . handleSelect } >
196
+ aria-selected = { this . isExpanded ( ) }
197
+ onClick = { this . handleSelect }
198
+ role = { headerRole } >
191
199
{ header }
192
200
</ a >
193
201
) ;
194
202
} ,
195
203
196
- renderCollapsibleTitle ( header ) {
204
+ renderCollapsibleTitle ( header , headerRole ) {
197
205
return (
198
206
< h4 className = { this . prefixClass ( 'title' ) } >
199
- { this . renderAnchor ( header ) }
207
+ { this . renderAnchor ( header , headerRole ) }
200
208
</ h4 >
201
209
) ;
202
210
} ,
0 commit comments