@aurora-ds/components 1.7.17 → 1.7.18

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/cjs/index.js CHANGED
@@ -3665,7 +3665,9 @@ const useMenuPanel = ({ open, onClose, anchorEl, minWidth, placement = 'bottom',
3665
3665
  }
3666
3666
  return Array.from(panelRef.current.querySelectorAll('[role^="menuitem"]:not([data-disabled]), [role="option"]:not([data-disabled])')).filter((el) => el.closest('[data-menu-panel]') === panelRef.current);
3667
3667
  }, []);
3668
- // On open: focus panel, initialise focusedIndex to checked/selected item (or 0)
3668
+ // On open: focus panel, pre-select a checked/selected item if any.
3669
+ // When nothing is pre-selected, leave focusedIndex at -1 so no item appears
3670
+ // highlighted on mouse-open — the first ArrowDown/Up will start navigation.
3669
3671
  React.useEffect(() => {
3670
3672
  if (!open) {
3671
3673
  setFocusedIndex(-1);
@@ -3675,7 +3677,7 @@ const useMenuPanel = ({ open, onClose, anchorEl, minWidth, placement = 'bottom',
3675
3677
  panelRef.current?.focus();
3676
3678
  const options = getOptions();
3677
3679
  const selectedIdx = options.findIndex((el) => el.getAttribute('aria-checked') === 'true' || el.getAttribute('data-selected') !== null);
3678
- setFocusedIndex(selectedIdx >= 0 ? selectedIdx : 0);
3680
+ setFocusedIndex(selectedIdx >= 0 ? selectedIdx : -1);
3679
3681
  });
3680
3682
  return () => cancelAnimationFrame(raf);
3681
3683
  }, [open, getOptions]);
@@ -3720,7 +3722,11 @@ const useMenuPanel = ({ open, onClose, anchorEl, minWidth, placement = 'bottom',
3720
3722
  e.preventDefault();
3721
3723
  setFocusedIndex((prev) => {
3722
3724
  const count = getOptions().length;
3723
- return count === 0 ? prev : (prev - 1 + count) % count;
3725
+ if (count === 0) {
3726
+ return prev;
3727
+ }
3728
+ // prev === -1 means no item focused yet → jump to last item
3729
+ return prev <= 0 ? count - 1 : prev - 1;
3724
3730
  });
3725
3731
  },
3726
3732
  ArrowRight: (e) => {