From c3f4bfd3bebf15c1ab5378acd5d678ae74552f70 Mon Sep 17 00:00:00 2001 From: Matthew Brookes Date: Wed, 27 Mar 2019 13:35:34 +0000 Subject: [PATCH] [Tabs] Improve accessibility --- docs/src/pages/components/tabs/SimpleTabs.js | 30 ++++++++++------- docs/src/pages/components/tabs/SimpleTabs.tsx | 32 ++++++++++++------- packages/material-ui/src/Tabs/Tabs.js | 2 +- 3 files changed, 40 insertions(+), 24 deletions(-) diff --git a/docs/src/pages/components/tabs/SimpleTabs.js b/docs/src/pages/components/tabs/SimpleTabs.js index c6373e5872b5f2..0f3cdc2e04c2de 100644 --- a/docs/src/pages/components/tabs/SimpleTabs.js +++ b/docs/src/pages/components/tabs/SimpleTabs.js @@ -6,15 +6,17 @@ import Tabs from '@material-ui/core/Tabs'; import Tab from '@material-ui/core/Tab'; import Typography from '@material-ui/core/Typography'; -function TabContainer(props) { +function TabPanel(props) { + const { children, ...other } = props; + return ( - - {props.children} + + {children} ); } -TabContainer.propTypes = { +TabPanel.propTypes = { children: PropTypes.node.isRequired, }; @@ -35,16 +37,22 @@ export default function SimpleTabs() { return (
- + - - - + + + - {value === 0 && Item One} - {value === 1 && Item Two} - {value === 2 && Item Three} + + +
); } diff --git a/docs/src/pages/components/tabs/SimpleTabs.tsx b/docs/src/pages/components/tabs/SimpleTabs.tsx index d025f823783c84..29638d63cace33 100644 --- a/docs/src/pages/components/tabs/SimpleTabs.tsx +++ b/docs/src/pages/components/tabs/SimpleTabs.tsx @@ -6,19 +6,21 @@ import Tabs from '@material-ui/core/Tabs'; import Tab from '@material-ui/core/Tab'; import Typography from '@material-ui/core/Typography'; -interface TabContainerProps { +interface TabPanelProps { children?: React.ReactNode; } -function TabContainer(props: TabContainerProps) { +function TabPanel(props: TabPanelProps) { + const { children, ...other } = props; + return ( - - {props.children} + + {children} ); } -TabContainer.propTypes = { +TabPanel.propTypes = { children: PropTypes.node.isRequired, }; @@ -41,16 +43,22 @@ export default function SimpleTabs() { return (
- + - - - + + + - {value === 0 && Item One} - {value === 1 && Item Two} - {value === 2 && Item Three} + + +
); } diff --git a/packages/material-ui/src/Tabs/Tabs.js b/packages/material-ui/src/Tabs/Tabs.js index ba7bbc038f70e1..e6d7cc3ba1f0c6 100644 --- a/packages/material-ui/src/Tabs/Tabs.js +++ b/packages/material-ui/src/Tabs/Tabs.js @@ -390,13 +390,13 @@ class Tabs extends React.Component { })} style={this.state.scrollerStyle} ref={this.handleTabsRef} - role="tablist" onScroll={this.handleTabsScroll} >
{children}