Skip to content

Commit

Permalink
[material-ui][docs] Add aria-current for nav tabs demo (mui#39594)
Browse files Browse the repository at this point in the history
Co-authored-by: siriwatknp <[email protected]>
Co-authored-by: Danilo Leal <[email protected]>
  • Loading branch information
3 people authored Dec 22, 2023
1 parent 5d2efe9 commit 9e798d8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
13 changes: 12 additions & 1 deletion docs/data/material/components/tabs/NavTabs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import Box from '@mui/material/Box';
import Tabs from '@mui/material/Tabs';
import Tab from '@mui/material/Tab';
Expand Down Expand Up @@ -27,11 +28,16 @@ function LinkTab(props) {
event.preventDefault();
}
}}
aria-current={props.selected && 'page'}
{...props}
/>
);
}

LinkTab.propTypes = {
selected: PropTypes.bool,
};

export default function NavTabs() {
const [value, setValue] = React.useState(0);

Expand All @@ -47,7 +53,12 @@ export default function NavTabs() {

return (
<Box sx={{ width: '100%' }}>
<Tabs value={value} onChange={handleChange} aria-label="nav tabs example">
<Tabs
value={value}
onChange={handleChange}
aria-label="nav tabs example"
role="navigation"
>
<LinkTab label="Page One" href="/drafts" />
<LinkTab label="Page Two" href="/trash" />
<LinkTab label="Page Three" href="/spam" />
Expand Down
9 changes: 8 additions & 1 deletion docs/data/material/components/tabs/NavTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function samePageLinkNavigation(
interface LinkTabProps {
label?: string;
href?: string;
selected?: boolean;
}

function LinkTab(props: LinkTabProps) {
Expand All @@ -34,6 +35,7 @@ function LinkTab(props: LinkTabProps) {
event.preventDefault();
}
}}
aria-current={props.selected && 'page'}
{...props}
/>
);
Expand All @@ -57,7 +59,12 @@ export default function NavTabs() {

return (
<Box sx={{ width: '100%' }}>
<Tabs value={value} onChange={handleChange} aria-label="nav tabs example">
<Tabs
value={value}
onChange={handleChange}
aria-label="nav tabs example"
role="navigation"
>
<LinkTab label="Page One" href="/drafts" />
<LinkTab label="Page Two" href="/trash" />
<LinkTab label="Page Three" href="/spam" />
Expand Down
7 changes: 6 additions & 1 deletion docs/data/material/components/tabs/NavTabs.tsx.preview
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<Tabs value={value} onChange={handleChange} aria-label="nav tabs example">
<Tabs
value={value}
onChange={handleChange}
aria-label="nav tabs example"
role="navigation"
>
<LinkTab label="Page One" href="/drafts" />
<LinkTab label="Page Two" href="/trash" />
<LinkTab label="Page Three" href="/spam" />
Expand Down

0 comments on commit 9e798d8

Please sign in to comment.