@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.cjs +11 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1684,6 +1684,9 @@ var React12 = __toESM(require("react"), 1);
|
|
|
1684
1684
|
var import_fractal_icons10 = require("@mirror-physics/fractal-icons");
|
|
1685
1685
|
|
|
1686
1686
|
// src/components/Dropdown/position.ts
|
|
1687
|
+
function isDropdownTriggerVisible(trigger, bounds) {
|
|
1688
|
+
return trigger.right > bounds.left && trigger.left < bounds.right && trigger.bottom > bounds.top && trigger.top < bounds.bottom;
|
|
1689
|
+
}
|
|
1687
1690
|
function positionDropdown(trigger, panel, bounds, direction, align) {
|
|
1688
1691
|
const gap = 4;
|
|
1689
1692
|
const width = Math.min(panel.width, Math.max(0, bounds.right - bounds.left));
|
|
@@ -1824,12 +1827,17 @@ function Dropdown({
|
|
|
1824
1827
|
bounds.bottom = Math.min(bounds.bottom, rect.top + ancestor.clientTop + ancestor.clientHeight);
|
|
1825
1828
|
}
|
|
1826
1829
|
}
|
|
1830
|
+
const triggerRect = trigger.getBoundingClientRect();
|
|
1831
|
+
if (!isDropdownTriggerVisible(triggerRect, bounds)) {
|
|
1832
|
+
focusOnOpen.current = false;
|
|
1833
|
+
setOpen(false);
|
|
1834
|
+
return false;
|
|
1835
|
+
}
|
|
1827
1836
|
const padding = Math.max(0, collisionPadding);
|
|
1828
1837
|
bounds.left += padding;
|
|
1829
1838
|
bounds.right = Math.max(bounds.left, bounds.right - padding);
|
|
1830
1839
|
bounds.top += padding;
|
|
1831
1840
|
bounds.bottom = Math.max(bounds.top, bounds.bottom - padding);
|
|
1832
|
-
const triggerRect = trigger.getBoundingClientRect();
|
|
1833
1841
|
const rootRect = root.getBoundingClientRect();
|
|
1834
1842
|
const availableWidth = bounds.right - bounds.left;
|
|
1835
1843
|
const heightLimit = Math.max(0, maxHeight);
|
|
@@ -1849,8 +1857,9 @@ function Dropdown({
|
|
|
1849
1857
|
panel.style[key] = `${nextStyle[key]}px`;
|
|
1850
1858
|
}
|
|
1851
1859
|
setPanelStyle((previous) => Object.entries(nextStyle).every(([key, value]) => previous[key] === value) ? previous : nextStyle);
|
|
1860
|
+
return true;
|
|
1852
1861
|
};
|
|
1853
|
-
updatePosition();
|
|
1862
|
+
if (!updatePosition()) return;
|
|
1854
1863
|
if (searchable && !panel.contains(document.activeElement)) searchRef.current?.focus({ preventScroll: true });
|
|
1855
1864
|
if (focusOnOpen.current) {
|
|
1856
1865
|
focusOnOpen.current = false;
|