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

[ListItem] Take the focusVisibleClassName property into account #11451

Merged
merged 4 commits into from
May 19, 2018
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
10 changes: 9 additions & 1 deletion packages/material-ui/src/ListItem/ListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class ListItem extends React.Component {
disabled,
disableGutters,
divider,
focusVisibleClassName,
...other
} = this.props;

Expand Down Expand Up @@ -105,7 +106,10 @@ class ListItem extends React.Component {

if (button) {
componentProps.component = componentProp || 'div';
componentProps.focusVisibleClassName = classes.focusVisible;
componentProps.focusVisibleClassName = classNames(
classes.focusVisible,
focusVisibleClassName,
);
Component = ButtonBase;
}

Expand Down Expand Up @@ -186,6 +190,10 @@ ListItem.propTypes = {
* If `true`, a 1px light border is added to the bottom of the list item.
*/
divider: PropTypes.bool,
/**
* @ignore
*/
focusVisibleClassName: PropTypes.string,
};

ListItem.defaultProps = {
Expand Down
11 changes: 11 additions & 0 deletions packages/material-ui/src/ListItem/ListItem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,15 @@ describe('<ListItem />', () => {
assert.strictEqual(wrapper.hasClass('bubu'), true);
});
});

describe('prop: focusVisibleClassName', () => {
it('should merge the class names', () => {
const wrapper = shallow(<ListItem button focusVisibleClassName="focusVisibleClassName" />);
assert.strictEqual(wrapper.props().component, 'div');
assert.strictEqual(
wrapper.props().focusVisibleClassName,
`${classes.focusVisible} focusVisibleClassName`,
);
});
});
});