Skip to content

Commit

Permalink
[Modal] Pass className from BackdropProps (#37399)
Browse files Browse the repository at this point in the history
  • Loading branch information
hbjORbj committed May 29, 2023
1 parent a6c93af commit 1bede6a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/mui-material/src/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ const Modal = React.forwardRef(function Modal(inProps, ref) {
backdrop: () => ({
...BackdropProps,
...resolveComponentProps(backdropSlotProps, ownerState),
className: clsx(backdropSlotProps?.className, classes?.backdrop),
className: clsx(
backdropSlotProps?.className,
BackdropProps?.className,
classes?.backdrop,
),
}),
}}
onTransitionEnter={() => setExited(false)}
Expand Down
11 changes: 11 additions & 0 deletions packages/mui-material/src/Modal/Modal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -828,4 +828,15 @@ describe('<Modal />', () => {
expect(within(getByTestId('parent')).getByTestId('child')).not.to.equal(null);
});
});

describe('prop: BackdropProps', () => {
it('should handle custom className', () => {
const { getByTestId } = render(
<Modal open BackdropProps={{ className: 'custom-backdrop', 'data-testid': 'backdrop' }}>
<div />
</Modal>,
);
expect(getByTestId('backdrop')).to.have.class('custom-backdrop');
});
});
});

0 comments on commit 1bede6a

Please sign in to comment.