@aurora-ds/components 1.7.19 → 1.7.20

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/esm/index.js CHANGED
@@ -3541,6 +3541,10 @@ const MENU_MIN_WIDTH_PX = 224;
3541
3541
  */
3542
3542
  const useMenuPosition = ({ anchorEl, open, menuRef, minWidth, gap = 4, placement = 'bottom', }) => {
3543
3543
  const [style, setStyle] = useState({});
3544
+ // Stays false until the rAF second pass has run with the real panel dimensions.
3545
+ // Keeps the panel invisible during the initial style={} state and the first
3546
+ // pass (menuHeight = 0) to prevent the position-jump flickering.
3547
+ const [isPositioned, setIsPositioned] = useState(false);
3544
3548
  const computePosition = useCallback(() => {
3545
3549
  if (!anchorEl) {
3546
3550
  return;
@@ -3621,14 +3625,19 @@ const useMenuPosition = ({ anchorEl, open, menuRef, minWidth, gap = 4, placement
3621
3625
  }
3622
3626
  else {
3623
3627
  setStyle({});
3628
+ setIsPositioned(false);
3624
3629
  }
3625
3630
  }, [open, computePosition]);
3626
- // Second pass: recompute after the panel renders to get actual height/width
3631
+ // Second pass: recompute after the panel renders to get actual height/width,
3632
+ // then mark as positioned so the panel becomes visible.
3627
3633
  useEffect(() => {
3628
3634
  if (!open) {
3629
3635
  return;
3630
3636
  }
3631
- const id = requestAnimationFrame(computePosition);
3637
+ const id = requestAnimationFrame(() => {
3638
+ computePosition();
3639
+ setIsPositioned(true);
3640
+ });
3632
3641
  return () => cancelAnimationFrame(id);
3633
3642
  }, [open, computePosition]);
3634
3643
  // Keep the menu glued to its anchor on scroll (nested containers) and resize.
@@ -3643,7 +3652,7 @@ const useMenuPosition = ({ anchorEl, open, menuRef, minWidth, gap = 4, placement
3643
3652
  window.removeEventListener('resize', computePosition);
3644
3653
  };
3645
3654
  }, [open, computePosition]);
3646
- return { style };
3655
+ return { style: { ...style, visibility: isPositioned ? 'visible' : 'hidden' } };
3647
3656
  };
3648
3657
 
3649
3658
  /** Custom DOM event fired on a submenu trigger item to request it opens. */