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] scrollButtons have an empty button error in compliance tools #15646

Merged
merged 4 commits into from
May 12, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/material-ui/src/Tabs/TabScrollButton.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable jsx-a11y/aria-role */

import React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
Expand Down Expand Up @@ -28,7 +30,15 @@ const TabScrollButton = React.forwardRef(function TabScrollButton(props, ref) {
}

return (
<ButtonBase className={className} onClick={onClick} ref={ref} tabIndex={-1} {...other}>
<ButtonBase
component="div"
className={className}
onClick={onClick}
ref={ref}
role={null}
tabIndex={null}
{...other}
>
{direction === 'left' ? <KeyboardArrowLeft /> : <KeyboardArrowRight />}
</ButtonBase>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/Tabs/Tabs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import TabScrollButton from './TabScrollButton';
import TabIndicator from './TabIndicator';

function AccessibleTabScrollButton(props) {
return <TabScrollButton aria-label={props.direction} {...props} />;
return <TabScrollButton data-direction={props.direction} {...props} />;
}
AccessibleTabScrollButton.propTypes = {
direction: PropTypes.string.isRequired,
};

const findScrollButton = (wrapper, direction) => wrapper.find(`button[aria-label="${direction}"]`);
const findScrollButton = (wrapper, direction) => wrapper.find(`div[data-direction="${direction}"]`);
const hasLeftScrollButton = wrapper => findScrollButton(wrapper, 'left').exists();
const hasRightScrollButton = wrapper => findScrollButton(wrapper, 'right').exists();

Expand Down