@underverse-ui/underverse 0.2.36 → 0.2.37
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/dist/index.cjs +19 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2606,13 +2606,30 @@ var Modal = ({
|
|
|
2606
2606
|
document.body.style.overflow = "unset";
|
|
2607
2607
|
};
|
|
2608
2608
|
}, [isOpen]);
|
|
2609
|
+
const isInsidePortal = (element) => {
|
|
2610
|
+
if (!element) return false;
|
|
2611
|
+
let current = element;
|
|
2612
|
+
while (current) {
|
|
2613
|
+
if (current.hasAttribute?.("data-datepicker") || current.hasAttribute?.("data-popover") || current.hasAttribute?.("data-dropdown") || current.hasAttribute?.("data-dropdown-menu") || current.hasAttribute?.("data-radix-popper-content-wrapper") || current.hasAttribute?.("data-radix-portal") || current.getAttribute?.("role") === "listbox" || current.getAttribute?.("role") === "dialog" || current.classList?.contains("datepicker-portal") || current.classList?.contains("popover-portal")) {
|
|
2614
|
+
return true;
|
|
2615
|
+
}
|
|
2616
|
+
current = current.parentElement;
|
|
2617
|
+
}
|
|
2618
|
+
return false;
|
|
2619
|
+
};
|
|
2609
2620
|
const handleOverlayMouseDown = (event) => {
|
|
2610
2621
|
mouseDownTarget.current = event.target;
|
|
2611
2622
|
};
|
|
2612
2623
|
const handleOverlayMouseUp = (event) => {
|
|
2613
2624
|
const modalContent2 = modalContentRef.current;
|
|
2614
|
-
const
|
|
2615
|
-
const
|
|
2625
|
+
const mouseDownTarget_ = mouseDownTarget.current;
|
|
2626
|
+
const mouseUpTarget = event.target;
|
|
2627
|
+
if (isInsidePortal(mouseDownTarget_) || isInsidePortal(mouseUpTarget)) {
|
|
2628
|
+
mouseDownTarget.current = null;
|
|
2629
|
+
return;
|
|
2630
|
+
}
|
|
2631
|
+
const mouseDownOutside = modalContent2 && !modalContent2.contains(mouseDownTarget_);
|
|
2632
|
+
const mouseUpOutside = modalContent2 && !modalContent2.contains(mouseUpTarget);
|
|
2616
2633
|
if (closeOnOverlayClick && mouseDownOutside && mouseUpOutside) {
|
|
2617
2634
|
onClose();
|
|
2618
2635
|
}
|