From 4bb7970234691d9849cc6c645c8026f0c2769333 Mon Sep 17 00:00:00 2001 From: Skyler Lehmkuhl Date: Tue, 14 Jul 2026 13:22:48 -0400 Subject: [PATCH] Keep menus alive for submenu interaction --- crates/egui/src/containers/menu.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/egui/src/containers/menu.rs b/crates/egui/src/containers/menu.rs index f2aaee04..a0caea51 100644 --- a/crates/egui/src/containers/menu.rs +++ b/crates/egui/src/containers/menu.rs @@ -515,6 +515,13 @@ impl SubMenu { content(ui) }); + if let Some(_) = &popup_response { + // Keep the submenu alive so `from_id`'s staleness check doesn't close it. + // Without this, menus whose content has no further SubMenuButtons never update + // `last_visible_pass`, causing the parent to reset `open_item` after ~2 frames. + MenuState::mark_shown(ui.ctx(), id); + } + if let Some(popup_response) = &popup_response { // If no child sub menu is open means we must be the deepest child sub menu. let is_deepest_submenu = MenuState::is_deepest_open_sub_menu(ui.ctx(), id);