{"record":{"id":"fe60883dea98d1dd","repo":"zed-industries/zed","slug":"visible-context-menu-should-always-render","errorCode":null,"errorMessage":"Visible context menu should always render.","messagePattern":"Visible context menu should always render\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/editor/src/element.rs","lineNumber":3970,"sourceCode":"                right: -right_margin - MENU_GAP,\n                ..Default::default()\n            });\n\n        let min_height = height_above_menu + min_menu_height + height_below_menu;\n        let max_height = height_above_menu + max_menu_height + height_below_menu;\n        let (laid_out_popovers, y_flipped) = self.layout_popovers_above_or_below_line(\n            target_position,\n            line_height,\n            min_height,\n            max_height,\n            context_menu_placement,\n            text_hitbox,\n            viewport_bounds,\n            window,\n            cx,\n            |height, max_width_for_stable_x, y_flipped, window, cx| {\n                // First layout the menu to get its size - others can be at least this wide.\n                let context_menu = if context_menu_visible {\n                    let menu_height = if y_flipped {\n                        height - height_below_menu\n                    } else {\n                        height - height_above_menu\n                    };\n                    let mut element = self\n                        .render_context_menu(line_height, menu_height, window, cx)\n                        .expect(\"Visible context menu should always render.\");\n                    let size = element.layout_as_root(AvailableSpace::min_size(), window, cx);\n                    Some((CursorPopoverType::CodeContextMenu, element, size))\n                } else {\n                    None\n                };\n                let min_width = context_menu\n                    .as_ref()\n                    .map_or(px(0.), |(_, _, size)| size.width);\n                let max_width = max_width_for_stable_x.max(\n                    context_menu","sourceCodeStart":3952,"sourceCodeEnd":3988,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/editor/src/element.rs#L3952-L3988","documentation":"An internal render invariant: during editor element paint, if context_menu_visible is true the code expects the context menu popover to produce an element and panics with 'Visible context menu should always render.' when layout returns none. It fires when visibility state and the actual menu element/handle get out of sync — e.g. the menu handle points to a menu that failed to build or was already dismissed while the visible flag still latched true.","triggerScenarios":"Thrown at crates/editor/src/element.rs:3893 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace the expect with a graceful skip: if the menu element is missing, render as if the menu were not visible","Clear context_menu_visible whenever the popover handle reports no active menu","Drive visibility from the same popover handle query used to fetch the element, so state cannot diverge"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}