@mirror-physics/fractal-ui 0.2.0-next.85 → 0.2.0-next.86

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
@@ -1427,6 +1427,9 @@ import * as React11 from "react";
1427
1427
  import { Close as Close2, Check as Check2, MagnifyingGlass as MagnifyingGlass2, ChevronDown, ChevronLeft, ChevronRight as ChevronRight2, ChevronUp } from "@mirror-physics/fractal-icons";
1428
1428
 
1429
1429
  // src/components/Dropdown/position.ts
1430
+ function isDropdownTriggerVisible(trigger, bounds) {
1431
+ return trigger.right > bounds.left && trigger.left < bounds.right && trigger.bottom > bounds.top && trigger.top < bounds.bottom;
1432
+ }
1430
1433
  function positionDropdown(trigger, panel, bounds, direction, align) {
1431
1434
  const gap = 4;
1432
1435
  const width = Math.min(panel.width, Math.max(0, bounds.right - bounds.left));
@@ -1567,12 +1570,17 @@ function Dropdown({
1567
1570
  bounds.bottom = Math.min(bounds.bottom, rect.top + ancestor.clientTop + ancestor.clientHeight);
1568
1571
  }
1569
1572
  }
1573
+ const triggerRect = trigger.getBoundingClientRect();
1574
+ if (!isDropdownTriggerVisible(triggerRect, bounds)) {
1575
+ focusOnOpen.current = false;
1576
+ setOpen(false);
1577
+ return false;
1578
+ }
1570
1579
  const padding = Math.max(0, collisionPadding);
1571
1580
  bounds.left += padding;
1572
1581
  bounds.right = Math.max(bounds.left, bounds.right - padding);
1573
1582
  bounds.top += padding;
1574
1583
  bounds.bottom = Math.max(bounds.top, bounds.bottom - padding);
1575
- const triggerRect = trigger.getBoundingClientRect();
1576
1584
  const rootRect = root.getBoundingClientRect();
1577
1585
  const availableWidth = bounds.right - bounds.left;
1578
1586
  const heightLimit = Math.max(0, maxHeight);
@@ -1592,8 +1600,9 @@ function Dropdown({
1592
1600
  panel.style[key] = `${nextStyle[key]}px`;
1593
1601
  }
1594
1602
  setPanelStyle((previous) => Object.entries(nextStyle).every(([key, value]) => previous[key] === value) ? previous : nextStyle);
1603
+ return true;
1595
1604
  };
1596
- updatePosition();
1605
+ if (!updatePosition()) return;
1597
1606
  if (searchable && !panel.contains(document.activeElement)) searchRef.current?.focus({ preventScroll: true });
1598
1607
  if (focusOnOpen.current) {
1599
1608
  focusOnOpen.current = false;