Skip to content

Commit

Permalink
[Tab] Do not override icon classname
Browse files Browse the repository at this point in the history
  • Loading branch information
hbjORbj committed Oct 12, 2021
1 parent f2fb8f5 commit f4f5d05
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/mui-material/src/Tab/Tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const Tab = React.forwardRef(function Tab(inProps, ref) {
const icon =
iconProp && label && React.isValidElement(iconProp)
? React.cloneElement(iconProp, {
className: classes.iconWrapper,
className: clsx(classes.iconWrapper, iconProp.props.className),
})
: iconProp;
const handleClick = (event) => {
Expand Down
5 changes: 3 additions & 2 deletions packages/mui-material/src/Tab/Tab.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,14 @@ describe('<Tab />', () => {
});

it('should add a classname when passed together with label', () => {
const { getByRole } = render(<Tab icon={<div data-testid="icon" />} label="foo" />);
const { getByRole } = render(<Tab icon={<div className="test-icon" />} label="foo" />);
const wrapper = getByRole('tab').children[0];
expect(wrapper).to.have.class(classes.iconWrapper);
expect(wrapper).to.have.class('test-icon');
});

it('should have bottom margin when passed together with label', () => {
const { getByRole } = render(<Tab icon={<div data-testid="icon" />} label="foo" />);
const { getByRole } = render(<Tab icon={<div />} label="foo" />);
const wrapper = getByRole('tab').children[0];
expect(wrapper).toHaveComputedStyle({ marginBottom: '6px' });
});
Expand Down

0 comments on commit f4f5d05

Please sign in to comment.