From 65435ec6434d1aa357de2c50d42fe9f8daa7a086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E7=88=B1=E5=90=83=E7=99=BD=E8=90=9D?= =?UTF-8?q?=E5=8D=9C?= Date: Fri, 11 Nov 2022 15:22:17 +0800 Subject: [PATCH] fix: Drawer mask not lock scroll (#350) --- src/Drawer.tsx | 3 ++- tests/index.spec.tsx | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Drawer.tsx b/src/Drawer.tsx index f7dd6a7f..e6761588 100644 --- a/src/Drawer.tsx +++ b/src/Drawer.tsx @@ -25,6 +25,7 @@ const Drawer: React.FC = props => { prefixCls, afterOpenChange, destroyOnClose, + mask, } = props; const [animatedVisible, setAnimatedVisible] = React.useState(false); @@ -57,7 +58,7 @@ const Drawer: React.FC = props => { open={open || forceRender || animatedVisible} autoDestroy={false} getContainer={getContainer} - autoLock={open || animatedVisible} + autoLock={mask && (open || animatedVisible)} > diff --git a/tests/index.spec.tsx b/tests/index.spec.tsx index b8d20d90..6a901def 100755 --- a/tests/index.spec.tsx +++ b/tests/index.spec.tsx @@ -131,7 +131,9 @@ describe('rc-drawer-menu', () => { const drawer = document.querySelector('.rc-drawer'); expect(drawer).toBeTruthy(); expect(document.body.contains(drawer)).toBeTruthy(); - expect(document.body.style.overflow).toBe(''); + expect(document.body).not.toHaveStyle({ + overflowY: 'hidden', + }); unmount(); });