Skip to content

Commit

Permalink
[Fab] Add disabled class to FAB button #34227
Browse files Browse the repository at this point in the history
  • Loading branch information
Meena Ramakrishnan authored and Meena Ramakrishnan committed Sep 13, 2022
1 parent 5f13a49 commit 3782714
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/mui-material/src/Fab/Fab.js
Expand Up @@ -9,11 +9,12 @@ import fabClasses, { getFabUtilityClass } from './fabClasses';
import styled from '../styles/styled';

const useUtilityClasses = (ownerState) => {
const { color, variant, classes, size } = ownerState;
const { color, variant, classes, size, disabled } = ownerState;

const slots = {
root: [
'root',
disabled && 'disabled',
variant,
`size${capitalize(size)}`,
color === 'inherit' ? 'colorInherit' : color,
Expand Down Expand Up @@ -159,7 +160,6 @@ const Fab = React.forwardRef(function Fab(inProps, ref) {
<FabRoot
className={clsx(classes.root, className)}
component={component}
disabled={disabled}
focusRipple={!disableFocusRipple}
focusVisibleClassName={clsx(classes.focusVisible, focusVisibleClassName)}
ownerState={ownerState}
Expand Down
7 changes: 7 additions & 0 deletions packages/mui-material/src/Fab/Fab.test.js
Expand Up @@ -142,6 +142,13 @@ describe('<Fab />', () => {
expect(button.querySelector('.pulsate-focus-visible')).to.equal(null);
});

it('should pass disabled class to ButtonBase', () => {
const disabledClassName = 'testDisabledClassName';
const { container } = render(<Fab disabled classes={{ disabled: disabledClassName }} />);

expect(container.querySelector('button')).to.have.class(disabledClassName);
});

it('should render Icon children with right classes', () => {
const childClassName = 'child-woof';
const iconChild = <Icon data-testid="icon" className={childClassName} />;
Expand Down

0 comments on commit 3782714

Please sign in to comment.