From 171eea0cd1a986dbec489988582c96a9a010e489 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Thu, 19 Nov 2026 14:45:12 +0000 Subject: [PATCH] look-rest-4: a side menu's selected row (the page shown) rests in the band its hover shows, as WordCraft's File menu marks its current page; a push Button drew no on look, so selected changed nothing; trial; the side menu story's current row shows it --- crates/ui-widgets/src/buttons/button.rs | 3 +++ crates/ui-widgets/tests/it/buttons.rs | 26 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/crates/ui-widgets/src/buttons/button.rs b/crates/ui-widgets/src/buttons/button.rs index 2b2ef0299b..4f543a1939 100644 --- a/crates/ui-widgets/src/buttons/button.rs +++ b/crates/ui-widgets/src/buttons/button.rs @@ -256,6 +256,9 @@ impl Component for Button<'_> { let pad = &cx.tokens.space.pad; style.text.role = TypeRole::BodyLarge; style.metrics.padding = Insets::new(pad.roomy, pad.roomy, pad.segment, pad.segment); + // The row of the page shown (`selected`) keeps the band its hover shows, so the menu marks where the page is. + let off = style.surface.fill.off; + style.surface.fill = style.surface.fill.clone().on(craft_theme::States::new(off.hover, off.hover, off.pressed, off.disabled)); } style } diff --git a/crates/ui-widgets/tests/it/buttons.rs b/crates/ui-widgets/tests/it/buttons.rs index fa76f72fbf..449662697f 100644 --- a/crates/ui-widgets/tests/it/buttons.rs +++ b/crates/ui-widgets/tests/it/buttons.rs @@ -507,3 +507,29 @@ fn a_side_menus_buttons_are_taller_rows_with_the_large_body_label() { let (menu, plain) = (rect(true, Arrangement::Stacked), rect(false, Arrangement::Stacked)); assert_eq!(menu.size(), plain.size(), "a stacked button keeps its own look in a side menu"); } + +/// The row of the page shown in a side menu (`selected`) keeps the band its hover shows, as WordCraft's File menu +/// marks its current page; a selected ghost button elsewhere keeps its own look. +#[trial] +fn a_side_menus_selected_row_shows_its_hover_band() { + let button = std::any::type_name::>(); + let (menu, _) = seen(button, "Info", |ui| { + with_env( + ui, + |overrides| { + overrides.values.set(ControlPlace::SideMenu); + }, + |ui| { + let _ = Button::new("Info").variant(Variant::GHOST).selected(true).show(ui); + }, + ); + }); + let (plain, _) = seen(button, "Info", |ui| { + let _ = Button::new("Info").variant(Variant::GHOST).selected(true).show(ui); + }); + let fill = menu.expect("a side menu's row has a surface").fill; + let on = fill.on.expect("a side menu's row has an on look"); + assert_eq!(on.rest, fill.off.hover, "the shown page's row rests in the hover band"); + assert_ne!(on.rest, fill.off.rest, "the shown page's row is marked"); + assert!(plain.expect("a ghost button has a surface").fill.on.is_none(), "a selected ghost button elsewhere keeps its look"); +}