Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const Drawer: React.FC<DrawerProps> = props => {
open={mergedOpen || forceRender || animatedVisible}
autoDestroy={false}
getContainer={getContainer}
autoLock={mask && (mergedOpen || animatedVisible)}
autoLock={mergedOpen || animatedVisible}
>
<DrawerPopup {...drawerPopupProps} />
</Portal>
Expand Down
19 changes: 17 additions & 2 deletions tests/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,10 @@ describe('rc-drawer-menu', () => {
});

describe('mask', () => {
it('mask false not lock body scroll', () => {
const { unmount } = render(<Drawer open mask={false} />);
it('not lock body scroll when getContainer is not body', () => {
const div = document.createElement('div');
document.body.appendChild(div);
const { unmount } = render(<Drawer open getContainer={() => div} />);
const drawer = document.querySelector('.rc-drawer');
expect(drawer).toBeTruthy();
expect(document.body.contains(drawer)).toBeTruthy();
Expand All @@ -154,6 +156,19 @@ describe('rc-drawer-menu', () => {
unmount();
});

it('lock body scroll when getContainer give document.body', () => {
const { unmount } = render(
<Drawer open getContainer={() => document.body} />,
);
const drawer = document.querySelector('.rc-drawer');
expect(drawer).toBeTruthy();
expect(document.body.contains(drawer)).toBeTruthy();
expect(document.body).toHaveStyle({
overflowY: 'hidden',
});
unmount();
});

it('maskClosable', () => {
const onClose = jest.fn();
const { container } = render(
Expand Down