@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 +9 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +9 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -3645,7 +3645,9 @@ const useMenuPanel = ({ open, onClose, anchorEl, minWidth, placement = 'bottom',
|
|
|
3645
3645
|
}
|
|
3646
3646
|
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);
|
|
3647
3647
|
}, []);
|
|
3648
|
-
// On open: focus panel,
|
|
3648
|
+
// On open: focus panel, pre-select a checked/selected item if any.
|
|
3649
|
+
// When nothing is pre-selected, leave focusedIndex at -1 so no item appears
|
|
3650
|
+
// highlighted on mouse-open — the first ArrowDown/Up will start navigation.
|
|
3649
3651
|
useEffect(() => {
|
|
3650
3652
|
if (!open) {
|
|
3651
3653
|
setFocusedIndex(-1);
|
|
@@ -3655,7 +3657,7 @@ const useMenuPanel = ({ open, onClose, anchorEl, minWidth, placement = 'bottom',
|
|
|
3655
3657
|
panelRef.current?.focus();
|
|
3656
3658
|
const options = getOptions();
|
|
3657
3659
|
const selectedIdx = options.findIndex((el) => el.getAttribute('aria-checked') === 'true' || el.getAttribute('data-selected') !== null);
|
|
3658
|
-
setFocusedIndex(selectedIdx >= 0 ? selectedIdx :
|
|
3660
|
+
setFocusedIndex(selectedIdx >= 0 ? selectedIdx : -1);
|
|
3659
3661
|
});
|
|
3660
3662
|
return () => cancelAnimationFrame(raf);
|
|
3661
3663
|
}, [open, getOptions]);
|
|
@@ -3700,7 +3702,11 @@ const useMenuPanel = ({ open, onClose, anchorEl, minWidth, placement = 'bottom',
|
|
|
3700
3702
|
e.preventDefault();
|
|
3701
3703
|
setFocusedIndex((prev) => {
|
|
3702
3704
|
const count = getOptions().length;
|
|
3703
|
-
|
|
3705
|
+
if (count === 0) {
|
|
3706
|
+
return prev;
|
|
3707
|
+
}
|
|
3708
|
+
// prev === -1 means no item focused yet → jump to last item
|
|
3709
|
+
return prev <= 0 ? count - 1 : prev - 1;
|
|
3704
3710
|
});
|
|
3705
3711
|
},
|
|
3706
3712
|
ArrowRight: (e) => {
|