@@ -60,26 +60,32 @@ const Panel = React.createClass({
6060 } ,
6161
6262 render ( ) {
63+ let { headerRole, panelRole, ...props } = this . props ;
6364 return (
64- < div { ...this . props }
65+ < div { ...props }
6566 className = { classNames ( this . props . className , this . getBsClassSet ( ) ) }
6667 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 ( ) }
6970 { this . renderFooter ( ) }
7071 </ div >
7172 ) ;
7273 } ,
7374
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+ }
7685
7786 return (
7887 < Collapse in = { this . isExpanded ( ) } >
79- < div
80- className = { collapseClass }
81- id = { this . props . id }
82- ref = 'panel' >
88+ < div { ...props } >
8389 { this . renderBody ( ) }
8490
8591 </ div >
@@ -148,7 +154,7 @@ const Panel = React.createClass({
148154 return React . isValidElement ( child ) && child . props . fill != null ;
149155 } ,
150156
151- renderHeading ( ) {
157+ renderHeading ( headerRole ) {
152158 let header = this . props . header ;
153159
154160 if ( ! header ) {
@@ -157,7 +163,7 @@ const Panel = React.createClass({
157163
158164 if ( ! React . isValidElement ( header ) || Array . isArray ( header ) ) {
159165 header = this . props . collapsible ?
160- this . renderCollapsibleTitle ( header ) : header ;
166+ this . renderCollapsibleTitle ( header , headerRole ) : header ;
161167 } else {
162168 const className = classNames (
163169 this . prefixClass ( 'title' ) , header . props . className
@@ -166,7 +172,7 @@ const Panel = React.createClass({
166172 if ( this . props . collapsible ) {
167173 header = cloneElement ( header , {
168174 className,
169- children : this . renderAnchor ( header . props . children )
175+ children : this . renderAnchor ( header . props . children , headerRole )
170176 } ) ;
171177 } else {
172178 header = cloneElement ( header , { className} ) ;
@@ -180,23 +186,25 @@ const Panel = React.createClass({
180186 ) ;
181187 } ,
182188
183- renderAnchor ( header ) {
189+ renderAnchor ( header , headerRole ) {
184190 return (
185191 < a
186192 href = { '#' + ( this . props . id || '' ) }
187193 aria-controls = { this . props . collapsible ? this . props . id : null }
188194 className = { this . isExpanded ( ) ? null : 'collapsed' }
189195 aria-expanded = { this . isExpanded ( ) }
190- onClick = { this . handleSelect } >
196+ aria-selected = { this . isExpanded ( ) }
197+ onClick = { this . handleSelect }
198+ role = { headerRole } >
191199 { header }
192200 </ a >
193201 ) ;
194202 } ,
195203
196- renderCollapsibleTitle ( header ) {
204+ renderCollapsibleTitle ( header , headerRole ) {
197205 return (
198206 < h4 className = { this . prefixClass ( 'title' ) } >
199- { this . renderAnchor ( header ) }
207+ { this . renderAnchor ( header , headerRole ) }
200208 </ h4 >
201209 ) ;
202210 } ,
0 commit comments