From 1e552cc508032e948e269bfcb2adbfab2b960b67 Mon Sep 17 00:00:00 2001 From: jquense Date: Thu, 18 Jun 2015 03:32:04 -0400 Subject: [PATCH] [added] Accessibility: use appropriate ARIA's when an id is given to the tabbed area --- src/TabPane.js | 6 +++++- src/TabbedArea.js | 20 +++++++++++++++---- test/TabPaneSpec.js | 19 ++++++++++++++++++ test/TabbedAreaSpec.js | 45 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 5 deletions(-) diff --git a/src/TabPane.js b/src/TabPane.js index bd41a6cf9e..3e36db3542 100644 --- a/src/TabPane.js +++ b/src/TabPane.js @@ -78,7 +78,11 @@ const TabPane = React.createClass({ }; return ( -
+
{this.props.children}
); diff --git a/src/TabbedArea.js b/src/TabbedArea.js index ee079244bd..fe51a57bf3 100644 --- a/src/TabbedArea.js +++ b/src/TabbedArea.js @@ -5,6 +5,9 @@ import ValidComponentChildren from './utils/ValidComponentChildren'; import Nav from './Nav'; import NavItem from './NavItem'; +let panelId = (props, child) => child.props.id ? child.props.id : props.id && (props.id + '___panel___' + child.props.eventKey); +let tabId = (props, child) => child.props.id ? child.props.id + '___tab' : props.id && (props.id + '___tab___' + child.props.eventKey); + function getDefaultActiveKeyFromChildren(children) { let defaultActiveKey; @@ -61,6 +64,8 @@ const TabbedArea = React.createClass({ }, render() { + let { id, ...props } = this.props; // eslint-disable-line object-shorthand + let activeKey = this.props.activeKey != null ? this.props.activeKey : this.state.activeKey; @@ -69,7 +74,7 @@ const TabbedArea = React.createClass({ } let nav = ( -