diff --git a/src/components/wordpress/layout-menu.tsx b/src/components/wordpress/layout-menu.tsx
index ecf61c3..8a45560 100644
--- a/src/components/wordpress/layout-menu.tsx
+++ b/src/components/wordpress/layout-menu.tsx
@@ -4,6 +4,7 @@ import {
forwardRef,
useCallback,
useEffect,
+ useId,
useMemo,
useState,
type HTMLAttributes,
@@ -24,7 +25,6 @@ import {
SidebarProvider,
useSidebarOptional,
} from "../ui/sidebar";
-import { Collapsible } from "@base-ui/react/collapsible";
/* ============================================
Sidebar provider detection
@@ -369,6 +369,7 @@ function MenuItemRenderer({
[item, activeItemId]
);
const [open, setOpen] = useState(containsActive);
+ const submenuId = useId();
// Auto-expand when a descendant becomes active
useEffect(() => {
@@ -378,9 +379,8 @@ function MenuItemRenderer({
const handleClick = useCallback(() => {
if (hasChildren) {
setOpen((o) => !o);
- } else {
- item.onClick?.();
}
+ item.onClick?.();
onItemClick?.(item);
}, [hasChildren, item, onItemClick]);
@@ -441,52 +441,47 @@ function MenuItemRenderer({
// Parent item with children at depth 0
if (hasChildren && depth === 0) {
return (
-
-
- onItemClick?.(item)}
+
+ : undefined}
+ tooltip={item.label}
+ isActive={isActive}
+ onClick={handleClick}
+ className={cn(
+ menuItemClassName,
+ isActive && activeItemClassName,
+ item.className,
+ )}
+ data-active={isActive || undefined}
+ disabled={item.disabled}
+ aria-expanded={open}
+ aria-controls={submenuId}
+ >
+ {item.icon && (
+ {item.icon}
+ )}
+
+ {item.label}
+ {item.secondaryLabel && (
+
- }
- >
- {item.icon && (
- {item.icon}
+ >
+ {item.secondaryLabel}
+
)}
-
- {item.label}
- {item.secondaryLabel && (
-
- {item.secondaryLabel}
-
- )}
-
-
-
-
- }
- >
+
+
+
+ {open && (
+
-
+
+ )}
+
);
}
@@ -529,6 +524,7 @@ function SubMenuItemRenderer({
[item, activeItemId]
);
const [open, setOpen] = useState(containsActive);
+ const submenuId = useId();
useEffect(() => {
if (containsActive) setOpen(true);
@@ -537,9 +533,8 @@ function SubMenuItemRenderer({
const handleClick = useCallback(() => {
if (hasChildren) {
setOpen((o) => !o);
- } else {
- item.onClick?.();
}
+ item.onClick?.();
onItemClick?.(item);
}, [hasChildren, item, onItemClick]);
@@ -582,38 +577,38 @@ function SubMenuItemRenderer({
// Nested parent sub-item
return (
-
-
- onItemClick?.(item)}
- className={cn(
- menuItemClassName,
- isActive && activeItemClassName,
- item.className,
- )}
- data-active={isActive || undefined}
- />
- }
- >
- {item.icon && (
- {item.icon}
+
+
+ :
+ }
+ isActive={isActive}
+ onClick={handleClick}
+ className={cn(
+ menuItemClassName,
+ isActive && activeItemClassName,
+ item.className,
+ )}
+ data-active={isActive || undefined}
+ aria-disabled={item.disabled || undefined}
+ aria-expanded={open}
+ aria-controls={submenuId}
+ >
+ {item.icon && (
+ {item.icon}
+ )}
+ {item.label}
+ {item.label}
-
-
-
- }
- >
+ />
+
+ {open && (
+
-
+
+ )}
+
);
}