x-ui-design 0.8.92 → 0.8.93
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 +9 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/lib/hooks/usePopupPosition.ts +11 -1
- 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 (
|
|
2656
|
+
if (popupRef.current) {
|
|
2657
2657
|
const popupRect = popupRef.current.getBoundingClientRect();
|
|
2658
2658
|
const availableSpace = {
|
|
2659
2659
|
top: container.top - (popupRect.height + OFFSET),
|
|
@@ -2674,6 +2674,14 @@ const usePopupPosition = ({
|
|
|
2674
2674
|
if (availableSpace.right < 0 && availableSpace.left > 0) {
|
|
2675
2675
|
newPlacement = newPlacement.replace('Left', 'Right');
|
|
2676
2676
|
}
|
|
2677
|
+
if (availableSpace.right < 0 && availableSpace.left < 0) {
|
|
2678
|
+
if (newPlacement.includes('Right')) {
|
|
2679
|
+
positions.left = popupRef.current.clientWidth - positions.left + container.left;
|
|
2680
|
+
}
|
|
2681
|
+
if (newPlacement.includes('Left')) {
|
|
2682
|
+
positions.left = positions.left - popupRef.current.clientWidth + container.width;
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2677
2685
|
_setPlacement(newPlacement);
|
|
2678
2686
|
}
|
|
2679
2687
|
if (e?.target === scrollableParents && inBody) {
|