From 643e66d1dfd91194476b801528e493573efe9d81 Mon Sep 17 00:00:00 2001 From: Dena DeBry Date: Thu, 19 Feb 2026 22:14:37 -0700 Subject: [PATCH 1/3] Refactor MenuItem to improve submenu rendering logic Update MenuItem component to conditionally render caret and submenu based on child items instead of expanded prop. --- decoupled-menu/src/main-menu.island.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/decoupled-menu/src/main-menu.island.tsx b/decoupled-menu/src/main-menu.island.tsx index e8ba563..2883bb4 100644 --- a/decoupled-menu/src/main-menu.island.tsx +++ b/decoupled-menu/src/main-menu.island.tsx @@ -349,6 +349,12 @@ const ListItem = styled.li<{ level?: number }>` } ` +/** + * Renders a single menu item (link and optional submenu). + * The caret and submenu are shown only when this item has children (items.length > 0). + * The `expanded` prop is accepted for API compatibility but is not used for display, + * consistent with our current documentation, which ignores this Drupal setting. + */ const MenuItem = ({id, title, url, items, expanded, level = 0}: { title: string, url: string, @@ -403,7 +409,8 @@ const MenuItem = ({id, title, url, items, expanded, level = 0}: { {title} } - {(items && expanded) && + {/* Show caret only when this item has child menu items (not based on expanded). */} + {items && items.length > 0 && <>