x-ui-design 0.9.27 → 0.9.29

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 CHANGED
@@ -2660,6 +2660,15 @@ const usePopupPosition = ({
2660
2660
  }
2661
2661
  const popupRect = popupRef.current?.getBoundingClientRect();
2662
2662
  if (popupRect) {
2663
+ if (!popupRect?.width) {
2664
+ setOpen(false);
2665
+ setPopupPosition({});
2666
+ const timeout = setTimeout(() => {
2667
+ setOpen(true);
2668
+ clearTimeout(timeout);
2669
+ }, 10);
2670
+ return;
2671
+ }
2663
2672
  const availableSpace = {
2664
2673
  top: container.top - (popupRect.height + OFFSET),
2665
2674
  bottom: (inBody ? window.innerHeight : scrollableParents?.clientHeight || 0) - (container.bottom + popupRect.height + OFFSET),
@@ -2669,14 +2678,12 @@ const usePopupPosition = ({
2669
2678
  let newPlacement = _placement;
2670
2679
  if (availableSpace.bottom < 0 && availableSpace.top > 0) {
2671
2680
  newPlacement = newPlacement.replace('bottom', 'top');
2672
- }
2673
- if (availableSpace.top < 0 && availableSpace.bottom > 0) {
2681
+ } else if (availableSpace.top < 0 && availableSpace.bottom > 0) {
2674
2682
  newPlacement = newPlacement.replace('top', 'bottom');
2675
2683
  }
2676
2684
  if (availableSpace.left < 0 && availableSpace.right > 0) {
2677
2685
  newPlacement = newPlacement.replace('Right', 'Left');
2678
- }
2679
- if (availableSpace.right < 0 && availableSpace.left > 0) {
2686
+ } else if (availableSpace.right < 0 && availableSpace.left > 0) {
2680
2687
  newPlacement = newPlacement.replace('Left', 'Right');
2681
2688
  }
2682
2689
  if (availableSpace.right < 0 && availableSpace.left < 0) {
@@ -2690,15 +2697,6 @@ const usePopupPosition = ({
2690
2697
  _setPlacement(newPlacement);
2691
2698
  }
2692
2699
  const _calculation = () => {
2693
- if (!popupRect?.width) {
2694
- setOpen(false);
2695
- setPopupPosition({});
2696
- const timeout = setTimeout(() => {
2697
- setOpen(true);
2698
- clearTimeout(timeout);
2699
- }, 0);
2700
- return;
2701
- }
2702
2700
  switch (_placement) {
2703
2701
  case "bottom":
2704
2702
  setPopupPosition({