x-ui-design 0.9.11 → 0.9.12
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.esm.js +6 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +6 -8
- package/dist/index.js.map +1 -1
- package/lib/hooks/usePopupPosition.ts +8 -10
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -2653,7 +2653,7 @@ const usePopupPosition = ({
|
|
|
2653
2653
|
top: (relativePosition.top || 0) + (targetRef.current?.offsetTop || 0) - (scrollableParents?.offsetTop || 0) + OFFSET,
|
|
2654
2654
|
left: relativePosition.left + (targetRef.current?.offsetLeft || 0) - (targetRef.current?.clientWidth || 0) / 2
|
|
2655
2655
|
};
|
|
2656
|
-
if (e?.target && inBody) {
|
|
2656
|
+
if (e?.target === scrollableParents && inBody) {
|
|
2657
2657
|
setOpen(false);
|
|
2658
2658
|
setPopupPosition({});
|
|
2659
2659
|
return;
|
|
@@ -2666,13 +2666,6 @@ const usePopupPosition = ({
|
|
|
2666
2666
|
left: container.left - (popupRect.width + OFFSET),
|
|
2667
2667
|
right: (inBody ? window.innerWidth : scrollableParents?.clientWidth || 0) - (container.right + popupRect.width + OFFSET)
|
|
2668
2668
|
};
|
|
2669
|
-
console.log({
|
|
2670
|
-
popupRect,
|
|
2671
|
-
container,
|
|
2672
|
-
scrollableParents,
|
|
2673
|
-
innerWidth: window.innerWidth,
|
|
2674
|
-
innerHeight: window.innerHeight
|
|
2675
|
-
});
|
|
2676
2669
|
let newPlacement = _placement;
|
|
2677
2670
|
if (availableSpace.bottom < 0 && availableSpace.top > 0) {
|
|
2678
2671
|
newPlacement = newPlacement.replace('bottom', 'top');
|
|
@@ -2694,6 +2687,10 @@ const usePopupPosition = ({
|
|
|
2694
2687
|
positions.left = positions.left - popupRef.current.clientWidth + container.width;
|
|
2695
2688
|
}
|
|
2696
2689
|
}
|
|
2690
|
+
console.log({
|
|
2691
|
+
newPlacement,
|
|
2692
|
+
availableSpace
|
|
2693
|
+
});
|
|
2697
2694
|
_setPlacement(newPlacement);
|
|
2698
2695
|
}
|
|
2699
2696
|
const _calculation = () => {
|
|
@@ -2763,6 +2760,7 @@ const usePopupPosition = ({
|
|
|
2763
2760
|
document.body.addEventListener("resize", calculatePosition, options);
|
|
2764
2761
|
return () => {
|
|
2765
2762
|
controller.abort();
|
|
2763
|
+
setPopupPosition({});
|
|
2766
2764
|
// setPositionRelative('unset');
|
|
2767
2765
|
};
|
|
2768
2766
|
}, [open, targetRef, popupContainer, inBody, calculatePosition]);
|