@@ -5,6 +5,9 @@ import ValidComponentChildren from './utils/ValidComponentChildren';
55import Nav from './Nav' ;
66import NavItem from './NavItem' ;
77
8+ let panelId = ( props , child ) => child . props . id ? child . props . id : props . id && ( props . id + '___panel___' + child . props . eventKey ) ;
9+ let tabId = ( props , child ) => child . props . id ? child . props . id + '___tab' : props . id && ( props . id + '___tab___' + child . props . eventKey ) ;
10+
811function getDefaultActiveKeyFromChildren ( children ) {
912 let defaultActiveKey ;
1013
@@ -61,6 +64,8 @@ const TabbedArea = React.createClass({
6164 } ,
6265
6366 render ( ) {
67+ let { id, ...props } = this . props ; // eslint-disable-line object-shorthand
68+
6469 let activeKey =
6570 this . props . activeKey != null ? this . props . activeKey : this . state . activeKey ;
6671
@@ -69,15 +74,15 @@ const TabbedArea = React.createClass({
6974 }
7075
7176 let nav = (
72- < Nav { ...this . props } activeKey = { activeKey } onSelect = { this . handleSelect } ref = "tabs" >
77+ < Nav { ...props } activeKey = { activeKey } onSelect = { this . handleSelect } ref = "tabs" >
7378 { ValidComponentChildren . map ( this . props . children , renderTabIfSet , this ) }
7479 </ Nav >
7580 ) ;
7681
7782 return (
7883 < div >
7984 { nav }
80- < div id = { this . props . id } className = "tab-content" ref = "panes" >
85+ < div id = { id } className = "tab-content" ref = "panes" >
8186 { ValidComponentChildren . map ( this . props . children , this . renderPane ) }
8287 </ div >
8388 </ div >
@@ -91,11 +96,15 @@ const TabbedArea = React.createClass({
9196 renderPane ( child , index ) {
9297 let activeKey = this . getActiveKey ( ) ;
9398
99+ let active = ( child . props . eventKey === activeKey &&
100+ ( this . state . previousActiveKey == null || ! this . props . animation ) ) ;
101+
94102 return cloneElement (
95103 child ,
96104 {
97- active : ( child . props . eventKey === activeKey &&
98- ( this . state . previousActiveKey == null || ! this . props . animation ) ) ,
105+ active,
106+ id : panelId ( this . props , child ) ,
107+ 'aria-labelledby' : tabId ( this . props , child ) ,
99108 key : child . key ? child . key : index ,
100109 animation : this . props . animation ,
101110 onAnimateOutEnd : ( this . state . previousActiveKey != null &&
@@ -106,9 +115,12 @@ const TabbedArea = React.createClass({
106115
107116 renderTab ( child ) {
108117 let { eventKey, className, tab, disabled } = child . props ;
118+
109119 return (
110120 < NavItem
121+ linkId = { tabId ( this . props , child ) }
111122 ref = { 'tab' + eventKey }
123+ aria-controls = { panelId ( this . props , child ) }
112124 eventKey = { eventKey }
113125 className = { className }
114126 disabled = { disabled } >
0 commit comments