Skip to content

Commit

Permalink
[ListItem] Take the focusVisibleClassName property into account (#11451)
Browse files Browse the repository at this point in the history
* fix : #11432 Take the focusVisibleClassName property into account

* fix : #11432 : Correct classNames call in ListItem.js

* chore: #11432 Add property description to the list-item.md file

* add a test
  • Loading branch information
rdemirov authored and oliviertassinari committed May 19, 2018
1 parent 04fae47 commit f686308
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/material-ui/src/ListItem/ListItem.js
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
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`,
);
});
});
});

0 comments on commit f686308

Please sign in to comment.