From b7c7183325fc0e9451689ffcfcd90dc24898868f Mon Sep 17 00:00:00 2001 From: skylartaylor Date: Wed, 25 Nov 2026 18:23:51 +0100 Subject: [PATCH] menu: the keyboard pane measures through MeasureCx::picture_size The pane worked its height out of `cx.room` by hand, which falls back to the least when the caps are measured in a column that offers no room, and which took the room even at `Proposal::Min`. `picture_size` keeps the least when there is no room or the measure is a least one, and tells the column to sweep again when the pane shows wider than it measured. --- crates/menu/src/shortcuts/keyboard.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/menu/src/shortcuts/keyboard.rs b/crates/menu/src/shortcuts/keyboard.rs index 5299517803..51ce1dc57b 100644 --- a/crates/menu/src/shortcuts/keyboard.rs +++ b/crates/menu/src/shortcuts/keyboard.rs @@ -412,12 +412,11 @@ impl Component for KeyCaps { fn measure(&mut self, cx: &MeasureCx<'_, Self>) -> Vec2 { // The caps keep their proportions: 18.5 units go across the pane and 6.25 down it, so the pane is as tall as // the width it is given makes the keys, and a wider pane draws bigger keys rather than the same keys one - // control high. A pane narrower than the keys ask for, or one with no bounded room, keeps the least height: - // the keys are never smaller than a control. + // control high. A pane given less room than the keys ask for, or measured at its least, keeps the least height, + // so the keys are never smaller than a control; a pane measured in a column that offers it no room still learns + // the height it shows at, as `picture_size` has the column sweep again with the width the pane settles on. let step = cx.style.step; - let least = vec2(UNITS_W * step, UNITS_H * step); - let width = cx.room.filter(|room| room.is_finite()).map_or(least.x, |room| room.max(least.x)); - vec2(least.x, width / UNITS_W * UNITS_H) + cx.picture_size(UNITS_W * step, f32::INFINITY, |width| width / UNITS_W * UNITS_H) } fn sense(&self) -> Sense {