[v10.0.x] Drawer: Fixes closeOnMaskClick false issue (#69103)
Drawer: Fixes closeOnMaskClick false issue (#69083)
(cherry picked from commit 1eed40fcf6)
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
This commit is contained in:
co-authored by
Torkel Ödegaard
parent
e5a71e81aa
commit
21f45c85d9
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user