fix(segmented_button): reset menu state when reopening context menu

When a context menu is open and the user right-clicks a different item,
the overlay's close handler resets the menu state but no longer captures
the event (since e10459f). The right-click propagates to the widget,
which reopens the menu with stale `MenuBounds` from the previous context
menu. If the new menu has a different number of items, this causes an
assertion failure in `MenuState::layout`.

Call `data.reset()` before setting `data.open = true` in the right-click
handler to ensure stale `MenuBounds` are cleared before the next layout
pass rebuilds them.
This commit is contained in:
Will Sheehan 2026-04-25 14:01:34 -07:00 committed by Michael Murphy
parent f3fc763b5f
commit 5825afb0da

View file

@ -1398,6 +1398,8 @@ where
state.context_cursor = cursor_position.position().unwrap_or_default();
state.menu_state.inner.with_data_mut(|data| {
// Clear stale MenuBounds from any previous context menu before opening a new one.
data.reset();
data.open = true;
data.view_cursor = cursor_position;
});