@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.js CHANGED
@@ -2449,13 +2449,30 @@ var Modal = ({
2449
2449
  document.body.style.overflow = "unset";
2450
2450
  };
2451
2451
  }, [isOpen]);
2452
+ const isInsidePortal = (element) => {
2453
+ if (!element) return false;
2454
+ let current = element;
2455
+ while (current) {
2456
+ 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")) {
2457
+ return true;
2458
+ }
2459
+ current = current.parentElement;
2460
+ }
2461
+ return false;
2462
+ };
2452
2463
  const handleOverlayMouseDown = (event) => {
2453
2464
  mouseDownTarget.current = event.target;
2454
2465
  };
2455
2466
  const handleOverlayMouseUp = (event) => {
2456
2467
  const modalContent2 = modalContentRef.current;
2457
- const mouseDownOutside = modalContent2 && !modalContent2.contains(mouseDownTarget.current);
2458
- const mouseUpOutside = modalContent2 && !modalContent2.contains(event.target);
2468
+ const mouseDownTarget_ = mouseDownTarget.current;
2469
+ const mouseUpTarget = event.target;
2470
+ if (isInsidePortal(mouseDownTarget_) || isInsidePortal(mouseUpTarget)) {
2471
+ mouseDownTarget.current = null;
2472
+ return;
2473
+ }
2474
+ const mouseDownOutside = modalContent2 && !modalContent2.contains(mouseDownTarget_);
2475
+ const mouseUpOutside = modalContent2 && !modalContent2.contains(mouseUpTarget);
2459
2476
  if (closeOnOverlayClick && mouseDownOutside && mouseUpOutside) {
2460
2477
  onClose();
2461
2478
  }