From 5825afb0dafe00353674ee47087de7183fc8a7c8 Mon Sep 17 00:00:00 2001 From: Will Sheehan Date: Sat, 25 Apr 2026 14:01:34 -0700 Subject: [PATCH] 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. --- src/widget/segmented_button/widget.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/widget/segmented_button/widget.rs b/src/widget/segmented_button/widget.rs index 44ca857..fcb1c59 100644 --- a/src/widget/segmented_button/widget.rs +++ b/src/widget/segmented_button/widget.rs @@ -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; });