Drawer: Fixes closeOnMaskClick false issue (#69083)

This commit is contained in:
Torkel Ödegaard 2023-05-25 19:43:48 +02:00 committed by GitHub
parent 4908045fc3
commit 1eed40fcf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -73,7 +73,8 @@ export function Drawer({
// Adds body class while open so the toolbar nav can hide some actions while drawer is open
useBodyClassWhileOpen();
useClickAway(overlayRef, onClose);
// Close when we click outside mask (topnav) but only if closeOnMaskClick is true
useClickAway(overlayRef, closeOnMaskClick ? onClose : doNothing);
// Apply size styles (unless deprecated width prop is used)
const rootClass = cx(styles.drawer, !width && styles.sizes[size]);
@ -142,6 +143,8 @@ export function Drawer({
);
}
function doNothing() {}
function useBodyClassWhileOpen() {
useEffect(() => {
if (!document.body) {