From 5355800d6dd6d7c8e96f154b4f977d8435ffe305 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 18 Nov 2026 15:13:45 +0000 Subject: [PATCH] rc-canvas-w8: red round 3 fix (canvas-run-3-fw) --- crates/ui-contract/src/contract/body/hooks.rs | 6 ++++-- crates/ui-contract/src/contract/cx/body.rs | 14 +++++++++++++- crates/ui-widgets/src/menu/popup.rs | 4 +++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/crates/ui-contract/src/contract/body/hooks.rs b/crates/ui-contract/src/contract/body/hooks.rs index d420f42cb..3c562dd3b 100644 --- a/crates/ui-contract/src/contract/body/hooks.rs +++ b/crates/ui-contract/src/contract/body/hooks.rs @@ -800,7 +800,8 @@ impl ShapeHooks for BodyHooks<'_> { if !real && is_open && props.end.is_some() { let mut end_cx = BodyCx::new(body_id, line_env.view(), resolved, regions.end, &mut *cx.core.memory, &mut open, gate.as_mut()) .with_field_message(field_message.clone()) - .with_owner(owner); + .with_owner(owner) + .with_exiting(self.exiting); close = close.or(self.end_region(comp, ui, &mut end_cx, &end_frame, &props, regions.end, None)); } let beside = @@ -1057,7 +1058,8 @@ impl ShapeHooks for BodyHooks<'_> { if real && props.end.is_some() { let mut end_cx = BodyCx::new(body_id, line_env.view(), resolved, regions.end, &mut *cx.core.memory, &mut open, gate.as_mut()) .with_field_message(field_message.clone()) - .with_owner(owner); + .with_owner(owner) + .with_exiting(self.exiting); // The end region shares the body's line, above a scroll bar under the body: its children sit on the // members' line, from the body's top (a label may stand above the body). let mut end = regions.end; diff --git a/crates/ui-contract/src/contract/cx/body.rs b/crates/ui-contract/src/contract/cx/body.rs index c021c2ed4..54cb59e44 100644 --- a/crates/ui-contract/src/contract/cx/body.rs +++ b/crates/ui-contract/src/contract/cx/body.rs @@ -28,6 +28,7 @@ pub struct BodyCx<'a> { gate: Option<&'a mut bool>, gate_mixed: bool, close: Option, + exiting: bool, field_message: Option<(Message, craft_theme::variant::Tone)>, owner: Option>, } @@ -43,7 +44,7 @@ impl<'a> BodyCx<'a> { gate: Option<&'a mut bool>, ) -> Self { memory.claim(id); - BodyCx { id, env, resolved, rect, memory, open, gate, gate_mixed: false, close: None, field_message: None, owner: None } + BodyCx { id, env, resolved, rect, memory, open, gate, gate_mixed: false, close: None, exiting: false, field_message: None, owner: None } } /// Asks the platform to open `url`, in a new tab where the platform has tabs and `new_tab` is set: the opener @@ -61,6 +62,17 @@ impl<'a> BodyCx<'a> { self.env.host()?.files().take_answer(ticket) } + pub(crate) fn with_exiting(mut self, exiting: bool) -> Self { + self.exiting = exiting; + self + } + + /// Whether the container has closed and its body only stays on screen while it fades out. `is_open` reads true + /// then; a region that belongs to the open container (a companion layer) is not shown. + pub fn is_exiting(&self) -> bool { + self.exiting + } + pub(crate) fn with_gate_mixed(mut self, mixed: bool) -> Self { self.gate_mixed = mixed; self diff --git a/crates/ui-widgets/src/menu/popup.rs b/crates/ui-widgets/src/menu/popup.rs index 6c806cab5..98d7f0a98 100644 --- a/crates/ui-widgets/src/menu/popup.rs +++ b/crates/ui-widgets/src/menu/popup.rs @@ -416,7 +416,9 @@ impl Container for Menu<'_> { /// menu. fn end(&mut self, ui: &mut Ui, cx: &mut BodyCx<'_>) { let Some(bar) = self.companion.as_mut() else { return }; - eprintln!("DIAG a_press_on_the_companion_bar_or_its_popup_does_not_close_the_menu_and_the_bar_closes_with_the_menu: companion end, open={}", cx.is_open()); + if cx.is_exiting() { + return; + } let label = Env::of(ui).words::().bar_companion.clone(); let _ = CompanionLayer::new(label).show(ui, |ui, _| bar(ui)); }