Skip to content

Commit

Permalink
add loadingPosition* classes to button
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp committed Jan 3, 2025
1 parent 02abe9d commit 0e87a59
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/mui-material/src/Button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ const useUtilityClasses = (ownerState) => {
`color${capitalize(color)}`,
disableElevation && 'disableElevation',
fullWidth && 'fullWidth',
loading && `loadingPosition${capitalize(loadingPosition)}`,
],
startIcon: ['icon', 'startIcon', `iconSize${capitalize(size)}`],
endIcon: ['icon', 'endIcon', `iconSize${capitalize(size)}`],
loadingIndicator: [
'loadingIndicator',
loading && `loadingPosition${capitalize(loadingPosition)}`,
],
loadingIndicator: ['loadingIndicator'],
loadingWrapper: ['loadingWrapper'],
};

Expand Down
19 changes: 19 additions & 0 deletions packages/mui-material/src/Button/Button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -810,5 +810,24 @@ describe('<Button />', () => {

expect(screen.getByRole('button')).to.have.text('loading…Test');
});

it('should have loading position class attached to root when `loading`', () => {
const { rerender } = render(<Button loading>Test</Button>);
expect(screen.getByRole('button')).to.have.class(classes.loadingPositionCenter);

rerender(
<Button loading loadingPosition="start">
Test
</Button>,
);
expect(screen.getByRole('button')).to.have.class(classes.loadingPositionStart);

rerender(
<Button loading loadingPosition="end">
Test
</Button>,
);
expect(screen.getByRole('button')).to.have.class(classes.loadingPositionEnd);
});
});
});

0 comments on commit 0e87a59

Please sign in to comment.