Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tabs] Fix aria-label issue on the demos #15507

Merged
merged 3 commits into from Apr 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/src/modules/components/AppContent.js
Expand Up @@ -36,7 +36,7 @@ function AppContent(props) {
<Container
component="main"
id="main-content"
tabIndex="-1"
tabIndex={-1}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because 1:

@types/react/index.d.ts

interface HTMLAttributes<T> extends DOMAttributes<T> {
  
  tabIndex?: number;

And 2: we use a number most of the time: consistency!

className={clsx(classes.root, className, {
[classes.disableToc]: disableToc,
})}
Expand Down
6 changes: 3 additions & 3 deletions docs/src/pages/demos/tabs/IconTabs.js
Expand Up @@ -31,9 +31,9 @@ function IconTabs() {
indicatorColor="primary"
textColor="primary"
>
<Tab icon={<PhoneIcon />} />
<Tab icon={<FavoriteIcon />} />
<Tab icon={<PersonPinIcon />} />
<Tab icon={<PhoneIcon />} aria-label="Phone" />
<Tab icon={<FavoriteIcon />} aria-label="Favorite" />
<Tab icon={<PersonPinIcon />} aria-label="Person" />
</Tabs>
</Paper>
);
Expand Down
6 changes: 3 additions & 3 deletions docs/src/pages/demos/tabs/IconTabs.tsx
Expand Up @@ -31,9 +31,9 @@ function IconTabs() {
indicatorColor="primary"
textColor="primary"
>
<Tab icon={<PhoneIcon />} />
<Tab icon={<FavoriteIcon />} />
<Tab icon={<PersonPinIcon />} />
<Tab icon={<PhoneIcon />} aria-label="Phone" />
<Tab icon={<FavoriteIcon />} aria-label="Favorite" />
<Tab icon={<PersonPinIcon />} aria-label="Person" />
</Tabs>
</Paper>
);
Expand Down
14 changes: 7 additions & 7 deletions docs/src/pages/demos/tabs/ScrollableTabsButtonPrevent.js
Expand Up @@ -45,13 +45,13 @@ function ScrollableTabsButtonPrevent() {
<div className={classes.root}>
<AppBar position="static">
<Tabs value={value} onChange={handleChange} variant="scrollable" scrollButtons="off">
<Tab icon={<PhoneIcon />} />
<Tab icon={<FavoriteIcon />} />
<Tab icon={<PersonPinIcon />} />
<Tab icon={<HelpIcon />} />
<Tab icon={<ShoppingBasket />} />
<Tab icon={<ThumbDown />} />
<Tab icon={<ThumbUp />} />
<Tab icon={<PhoneIcon />} aria-label="Phone" />
<Tab icon={<FavoriteIcon />} aria-label="Favorite" />
<Tab icon={<PersonPinIcon />} aria-label="Person" />
<Tab icon={<HelpIcon />} aria-label="Help" />
<Tab icon={<ShoppingBasket />} aria-label="Shopping" />
<Tab icon={<ThumbDown />} aria-label="Up" />
<Tab icon={<ThumbUp />} aria-label="Down" />
</Tabs>
</AppBar>
{value === 0 && <TabContainer>Item One</TabContainer>}
Expand Down
14 changes: 7 additions & 7 deletions docs/src/pages/demos/tabs/ScrollableTabsButtonPrevent.tsx
Expand Up @@ -49,13 +49,13 @@ function ScrollableTabsButtonPrevent() {
<div className={classes.root}>
<AppBar position="static">
<Tabs value={value} onChange={handleChange} variant="scrollable" scrollButtons="off">
<Tab icon={<PhoneIcon />} />
<Tab icon={<FavoriteIcon />} />
<Tab icon={<PersonPinIcon />} />
<Tab icon={<HelpIcon />} />
<Tab icon={<ShoppingBasket />} />
<Tab icon={<ThumbDown />} />
<Tab icon={<ThumbUp />} />
<Tab icon={<PhoneIcon />} aria-label="Phone" />
<Tab icon={<FavoriteIcon />} aria-label="Favorite" />
<Tab icon={<PersonPinIcon />} aria-label="Person" />
<Tab icon={<HelpIcon />} aria-label="Help" />
<Tab icon={<ShoppingBasket />} aria-label="Shopping" />
<Tab icon={<ThumbDown />} aria-label="Up" />
<Tab icon={<ThumbUp />} aria-label="Down" />
</Tabs>
</AppBar>
{value === 0 && <TabContainer>Item One</TabContainer>}
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Backdrop/Backdrop.js
Expand Up @@ -39,7 +39,7 @@ const Backdrop = React.forwardRef(function Backdrop(props, ref) {
},
className,
)}
aria-hidden="true"
aria-hidden
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have looked at it on reach-ui side, they use both interchangeably. How does it work?

aria-hidden -> shorthand notation expension aria-hidden={true} -> DOM string casting aria-hidden="true"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a special terminology for this in the DOM spec but in the end these types of attributes just need to exist. No need to pass a value.

ref={ref}
/>
</Fade>
Expand Down
Expand Up @@ -18,7 +18,7 @@ const styles = {
function BreadcrumbSeparator(props) {
const { classes, className, ...other } = props;

return <li aria-hidden="true" className={clsx(classes.root, className)} {...other} />;
return <li aria-hidden className={clsx(classes.root, className)} {...other} />;
}

BreadcrumbSeparator.propTypes = {
Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/ButtonBase/ButtonBase.js
Expand Up @@ -309,7 +309,7 @@ class ButtonBase extends React.Component {
setRef(buttonRef, ref);
setRef(innerRef, ref);
}}
tabIndex={disabled ? '-1' : tabIndex}
tabIndex={disabled ? -1 : tabIndex}
{...buttonProps}
{...other}
>
Expand Down Expand Up @@ -468,7 +468,7 @@ ButtonBase.defaultProps = {
disableRipple: false,
disableTouchRipple: false,
focusRipple: false,
tabIndex: '0',
tabIndex: 0,
type: 'button',
};

Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/ButtonBase/ButtonBase.test.js
Expand Up @@ -50,7 +50,7 @@ describe('<ButtonBase />', () => {
it('should change the button component and add accessibility requirements', () => {
const wrapper = mount(<ButtonBase component="span" role="checkbox" aria-checked={false} />);
const checkbox = wrapper.find('span[role="checkbox"]');
assert.strictEqual(checkbox.props().tabIndex, '0');
assert.strictEqual(checkbox.props().tabIndex, 0);
});

it('should not apply role="button" if type="button"', () => {
Expand Down Expand Up @@ -381,7 +381,7 @@ describe('<ButtonBase />', () => {
describe('prop: disabled', () => {
it('should not receive the focus', () => {
const wrapper = mount(<ButtonBase disabled>Hello</ButtonBase>);
assert.strictEqual(wrapper.find('button').props().tabIndex, '-1');
assert.strictEqual(wrapper.find('button').props().tabIndex, -1);
});

it('should also apply it when using component', () => {
Expand Down
Expand Up @@ -136,7 +136,7 @@ const ExpansionPanelSummary = React.forwardRef(function ExpansionPanelSummary(pr
edge="end"
component="div"
tabIndex={-1}
aria-hidden="true"
aria-hidden
{...IconButtonProps}
>
{expandIcon}
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Icon/Icon.js
Expand Up @@ -63,7 +63,7 @@ const Icon = React.forwardRef(function Icon(props, ref) {
},
className,
)}
aria-hidden="true"
aria-hidden
ref={ref}
{...other}
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/InputBase/Textarea.js
Expand Up @@ -127,7 +127,7 @@ const Textarea = React.forwardRef(function Textarea(props, ref) {
{...other}
/>
<textarea
aria-hidden="true"
aria-hidden
className={props.className}
readOnly
ref={shadowRef}
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Modal/SimpleBackdrop.js
Expand Up @@ -31,7 +31,7 @@ const SimpleBackdrop = React.forwardRef(function SimpleBackdrop(props, ref) {
return open ? (
<div
data-mui-test="Backdrop"
aria-hidden="true"
aria-hidden
ref={ref}
{...other}
style={{
Expand Down