@turnit-ou/shared 2.18.2 → 2.18.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/DrawerForm.js +6 -5
- package/package.json +1 -1
package/components/DrawerForm.js
CHANGED
|
@@ -68,9 +68,9 @@ export function DrawerForm(inProps) {
|
|
|
68
68
|
const handleClickClose = useCallback((event) => {
|
|
69
69
|
onClose?.(event, 'close');
|
|
70
70
|
}, [onClose]);
|
|
71
|
-
// MUI's ClickAwayListener only skips the
|
|
72
|
-
// stays mounted while closed, so
|
|
73
|
-
//
|
|
71
|
+
// MUI's ClickAwayListener only skips the event that mounted it. This one
|
|
72
|
+
// stays mounted while closed, so a drawer opened from a mouseup handler
|
|
73
|
+
// would receive that same mouseup as an outside click and close straight away.
|
|
74
74
|
const clickAwayArmedRef = useRef(false);
|
|
75
75
|
useEffect(() => {
|
|
76
76
|
if (!open) {
|
|
@@ -85,7 +85,8 @@ export function DrawerForm(inProps) {
|
|
|
85
85
|
};
|
|
86
86
|
}, [open]);
|
|
87
87
|
const handleClickAway = useCallback((event) => {
|
|
88
|
-
|
|
88
|
+
const isNonPrimaryButton = 'button' in event && event.button !== 0;
|
|
89
|
+
if (clickAwayArmedRef.current && !isNonPrimaryButton) {
|
|
89
90
|
onClose?.(event, 'backdropClick');
|
|
90
91
|
}
|
|
91
92
|
}, [onClose]);
|
|
@@ -96,7 +97,7 @@ export function DrawerForm(inProps) {
|
|
|
96
97
|
// why MUI's own aria-hidden is not enough here).
|
|
97
98
|
const drawerRef = useRef(null);
|
|
98
99
|
useInertBackground(Boolean(open), drawerRef);
|
|
99
|
-
return (_jsx(ClickAwayListener, { onClickAway: handleClickAway, children: _jsx(Drawer, { ref: drawerRef, anchor: "right", open: open, onClose: onClose, className: classNames(classes.modal, className), disablePortal: true, hideBackdrop: true, PaperProps: {
|
|
100
|
+
return (_jsx(ClickAwayListener, { mouseEvent: "onMouseUp", onClickAway: handleClickAway, children: _jsx(Drawer, { ref: drawerRef, anchor: "right", open: open, onClose: onClose, className: classNames(classes.modal, className), disablePortal: true, hideBackdrop: true, PaperProps: {
|
|
100
101
|
className: classes.paper,
|
|
101
102
|
elevation: 4,
|
|
102
103
|
square: true,
|