Skip to content

Commit 26eddd8

Browse files
andreakarashoclaude
andcommitted
Fix submenu closing parent dropdown due to InsideMenuBar state corruption
BeginSubmenu didn't increment MenuBarMenuDepth, so EndMenu for a nested submenu prematurely restored InsideMenuBar=true. This caused subsequent BeginMenu calls in the same dropdown to route through BeginMenuBarMenu, triggering hover-to-switch logic that closed the parent dropdown. Also make MenuItem participate in HoveredMenuItemId tracking so sibling submenus properly close when hovering regular menu items. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4dab9b5 commit 26eddd8

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/Clay/ClayUI.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3972,6 +3972,13 @@ public static bool MenuItem(string label, bool enabled = true)
39723972
bool isHovered = IsHovered(id) && enabled;
39733973
bool clicked = isHovered && ShouldProcessClick;
39743974

3975+
// Participate in the hovered-menu-item system so sibling submenus close
3976+
if (isHovered && _context.HoveredMenuItemId != id.Id)
3977+
{
3978+
_context.HoveredMenuItemId = id.Id;
3979+
_context.HoveredMenuItemTime = 0;
3980+
}
3981+
39753982
var s = Style.Popup;
39763983
var textColor = enabled ? Color.White : Color.Rgba(120, 120, 125);
39773984
var bgColor = isHovered ? Color.Rgba(60, 60, 70) : Color.Transparent;
@@ -4257,7 +4264,13 @@ private static bool BeginSubmenu(string label, bool enabled)
42574264
});
42584265
}
42594266

4260-
return BeginPopup(menuKey, s with { Offset = default });
4267+
bool result = BeginPopup(menuKey, s with { Offset = default });
4268+
if (result)
4269+
{
4270+
// Track depth so EndMenu doesn't prematurely restore InsideMenuBar
4271+
_context.MenuBarMenuDepth++;
4272+
}
4273+
return result;
42614274
}
42624275

42634276
/// <summary>

0 commit comments

Comments
 (0)