Skip to content

Commit

Permalink
[SwipeableDrawer] Fix missing close animation when initial open is tr…
Browse files Browse the repository at this point in the history
…ue (#35010)

Co-authored-by: ZeeshanTamboli <zeeshan.tamboli@gmail.com>
  • Loading branch information
sai6855 and ZeeshanTamboli committed Dec 6, 2022
1 parent f4be7ab commit cd27859
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/mui-base/src/ModalUnstyled/ModalUnstyled.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const ModalUnstyled = React.forwardRef(function ModalUnstyled(props, ref) {
...other
} = props;

const [exited, setExited] = React.useState(true);
const [exited, setExited] = React.useState(!open);
const modal = React.useRef({});
const mountNodeRef = React.useRef(null);
const modalRef = React.useRef(null);
Expand Down
18 changes: 18 additions & 0 deletions packages/mui-base/src/ModalUnstyled/ModalUnstyled.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ describe('<ModalUnstyled />', () => {
expect(theme).not.to.equal(null);
});

it('default exited state is opposite of open prop', () => {
let exited = null;

const Root = React.forwardRef(({ ownerState: ownerStateProp, ...other }, ref) => {
exited = ownerStateProp.exited;

return <span ref={ref} {...other} />;
});

render(
<ModalUnstyled open slots={{ root: Root }}>
<div />
</ModalUnstyled>,
);

expect(exited).to.equal(false);
});

it('does not forward style props as DOM attributes if component slot is primitive', () => {
const elementRef = React.createRef();
render(
Expand Down

0 comments on commit cd27859

Please sign in to comment.