{"record":{"id":"e224515e84b4caf1","repo":"emilk/egui","slug":"we-should-always-find-the-root","errorCode":null,"errorMessage":"We should always find the root","messagePattern":"We should always find the root","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/egui/src/containers/menu.rs","lineNumber":40,"sourceCode":"pub fn menu_style(style: &mut Style) {\n    style.spacing.button_padding = vec2(2.0, 0.0);\n    style.visuals.widgets.active.bg_stroke = Stroke::NONE;\n    style.visuals.widgets.open.bg_stroke = Stroke::NONE;\n    style.visuals.widgets.hovered.bg_stroke = Stroke::NONE;\n    style.visuals.widgets.inactive.weak_bg_fill = Color32::TRANSPARENT;\n    style.visuals.widgets.inactive.bg_stroke = Stroke::NONE;\n}\n\n/// Find the root [`UiStack`] of the menu.\npub fn find_menu_root(ui: &Ui) -> &UiStack {\n    ui.stack()\n        .iter()\n        .find(|stack| {\n            stack.is_root_ui()\n                || [Some(UiKind::Popup), Some(UiKind::Menu)].contains(&stack.kind())\n                || stack.info.tags.contains(MenuConfig::MENU_CONFIG_TAG)\n        })\n        .expect(\"We should always find the root\")\n}\n\n/// Is this Ui part of a menu?\n///\n/// Returns `false` if this is a menu bar.\n/// Should be used to determine if we should show a menu button or submenu button.\npub fn is_in_menu(ui: &Ui) -> bool {\n    for stack in ui.stack().iter() {\n        if let Some(config) = stack\n            .info\n            .tags\n            .get_downcast::<MenuConfig>(MenuConfig::MENU_CONFIG_TAG)\n        {\n            return !config.bar;\n        }\n        if [Some(UiKind::Popup), Some(UiKind::Menu)].contains(&stack.kind()) {\n            return true;\n        }","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/emilk/egui/blob/d802a982ce959839d92f4f6718fdffa41143110e/crates/egui/src/containers/menu.rs#L22-L58","documentation":"Error \"We should always find the root\" thrown in emilk/egui.","triggerScenarios":"Thrown at crates/egui/src/containers/menu.rs:40 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d802a982ce959839d92f4f6718fdffa41143110e","analyzedAt":"2026-08-16T20:07:53.954Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}