@inf-monkeys-tech/monkeys-design 1.0.18 → 1.0.19

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.
@@ -3634,6 +3634,7 @@ function HeadbarNavMenuItem({
3634
3634
  }) {
3635
3635
  const [open, setOpen] = useState(false);
3636
3636
  const closeTimerRef = useRef(null);
3637
+ const wasOpenOnPointerDownRef = useRef(false);
3637
3638
  const clearCloseTimer = () => {
3638
3639
  if (!closeTimerRef.current) return;
3639
3640
  clearTimeout(closeTimerRef.current);
@@ -3650,6 +3651,13 @@ function HeadbarNavMenuItem({
3650
3651
  closeTimerRef.current = null;
3651
3652
  }, 120);
3652
3653
  };
3654
+ const navigateToFirstEnabledChild = () => {
3655
+ const firstEnabledChild = item.children?.find((child) => !child.disabled);
3656
+ if (!firstEnabledChild) return false;
3657
+ setOpen(false);
3658
+ onNavigate?.(firstEnabledChild.id);
3659
+ return true;
3660
+ };
3653
3661
  useEffect(() => clearCloseTimer, []);
3654
3662
  return /* @__PURE__ */ jsxs(DropdownMenu.Root, { modal: false, open, onOpenChange: setOpen, children: [
3655
3663
  /* @__PURE__ */ jsx(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
@@ -3662,7 +3670,22 @@ function HeadbarNavMenuItem({
3662
3670
  endIcon: /* @__PURE__ */ jsx(HeadbarChevronIcon, { open }),
3663
3671
  label: /* @__PURE__ */ jsx("span", { className: "truncate whitespace-nowrap", children: label }),
3664
3672
  disabled: item.disabled,
3665
- onClick: () => setOpen(true),
3673
+ onClick: () => {
3674
+ const wasOpenOnPointerDown = wasOpenOnPointerDownRef.current;
3675
+ wasOpenOnPointerDownRef.current = false;
3676
+ if (wasOpenOnPointerDown && navigateToFirstEnabledChild()) return;
3677
+ setOpen(true);
3678
+ },
3679
+ onPointerDown: () => {
3680
+ wasOpenOnPointerDownRef.current = open;
3681
+ },
3682
+ onPointerCancel: () => {
3683
+ wasOpenOnPointerDownRef.current = false;
3684
+ },
3685
+ onKeyDown: (event) => {
3686
+ if (!open || event.key !== "Enter" && event.key !== " ") return;
3687
+ if (navigateToFirstEnabledChild()) event.preventDefault();
3688
+ },
3666
3689
  onMouseEnter: openMenu,
3667
3690
  onMouseLeave: scheduleCloseMenu,
3668
3691
  style: getHeadbarItemStyle(isActive || open, useTokenRadius),
@@ -3701,7 +3724,7 @@ function HeadbarNavMenuItem({
3701
3724
  {
3702
3725
  disabled: child.disabled,
3703
3726
  className: cn2(
3704
- "relative flex cursor-pointer select-none items-center gap-2.5 px-3 py-2 text-sm outline-none transition-colors hover:bg-[var(--monkeys-component-navigation-headbar-item-hover-background,hsl(var(--accent)))]",
3727
+ "relative flex cursor-pointer select-none items-center gap-2.5 px-3 py-2 text-sm outline-none transition-colors hover:bg-[var(--monkeys-component-navigation-headbar-item-hover-background,hsl(var(--accent)))] focus:bg-[var(--monkeys-component-navigation-headbar-item-hover-background,hsl(var(--accent)))] [&[data-highlighted]]:bg-[var(--monkeys-component-navigation-headbar-item-hover-background,hsl(var(--accent)))]",
3705
3728
  menuItemRadiusClass
3706
3729
  ),
3707
3730
  style: getHeadbarItemStyle(