@dloizides/ui-layout 1.26.0 → 1.26.2

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.js CHANGED
@@ -460,6 +460,10 @@ function observeLayout(node, onChange) {
460
460
  observer.observe(document.body);
461
461
  return observer;
462
462
  }
463
+ function isSameRect(a, b) {
464
+ if (a === null || b === null) return a === b;
465
+ return a.top === b.top && a.left === b.left && a.width === b.width && a.bottom === b.bottom;
466
+ }
463
467
  function useAnchorTracking(containerRef, onOutOfView) {
464
468
  const [rect, setRect] = React10.useState(() => readAnchorRect(containerRef));
465
469
  React10.useLayoutEffect(() => {
@@ -471,7 +475,7 @@ function useAnchorTracking(containerRef, onOutOfView) {
471
475
  frame = null;
472
476
  if (isDisposed) return;
473
477
  const next = readAnchorRect(containerRef);
474
- setRect(next);
478
+ setRect((previous) => isSameRect(previous, next) ? previous : next);
475
479
  const isHidden = next !== null && isAnchorHidden(next, readClipBounds(toDomNode(containerRef)), MIN_VISIBLE_PX);
476
480
  if (hasMeasured && isHidden) onOutOfView();
477
481
  hasMeasured = true;
@@ -592,6 +596,7 @@ var InlineMenu = ({
592
596
  value,
593
597
  options,
594
598
  containerRef,
599
+ isOpen,
595
600
  optionTestID,
596
601
  menuMinWidth = 0,
597
602
  animatedStyle,
@@ -623,7 +628,7 @@ var InlineMenu = ({
623
628
  useMenuKeyboard({
624
629
  containerRef,
625
630
  menuRef,
626
- enabled: true,
631
+ enabled: isOpen,
627
632
  itemCount: options.length,
628
633
  onHighlightChange: setHighlightedIndex,
629
634
  onSelectHighlighted: selectHighlighted,
@@ -862,6 +867,7 @@ var ModalDropdown = ({
862
867
  accessibilityLabel,
863
868
  animatedStyle: menuAnim.style,
864
869
  containerRef: anchorRef,
870
+ isOpen,
865
871
  menuMinWidth,
866
872
  optionTestID: optionTestIDFor,
867
873
  options,