From 35c78eaf3d2b6ea06fb890262ad3227a862e50e1 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 22 Nov 2026 07:05:30 -0500 Subject: [PATCH] Summary card: the description wraps onto its two reserved lines --- crates/ui-widgets/src/tile_grid/tile.rs | 9 ++++++-- crates/ui-widgets/tests/it/tile_grid/tile.rs | 24 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/crates/ui-widgets/src/tile_grid/tile.rs b/crates/ui-widgets/src/tile_grid/tile.rs index 6f4547f9d..bc7644844 100644 --- a/crates/ui-widgets/src/tile_grid/tile.rs +++ b/crates/ui-widgets/src/tile_grid/tile.rs @@ -996,8 +996,13 @@ impl Component for Tile<'_> { draw.galley(egui::pos2(title_x, title_area.top()), &title_layout); if !centered { if let Some(detail) = &self.detail { - let run = TextRun::new(detail.as_str()).role(style.detail.role).color(cx.resolve(&style.detail.color)).elide(); - let layout = draw.layout(&run, picture.width()); + // The description wraps, onto the two lines the card reserves for it, as production's cards do. + let run = TextRun::new(detail.as_str()).role(style.detail.role).color(cx.resolve(&style.detail.color)).wrap(Wrap::Wrap); + let mut layout = draw.layout(&run, picture.width()); + // More than the two reserved lines would run into the action: cut that description with an ellipsis. + if layout.galley.rows.len() > 2 { + layout = draw.layout(&run.elide(), picture.width()); + } draw.galley(egui::pos2(self.text_x(picture, layout.size().x, cx), icon.bottom() + style.sizes.tight), &layout); } let run = TextRun::new(action.as_str()).role(style.detail.role).color(style.range).elide(); diff --git a/crates/ui-widgets/tests/it/tile_grid/tile.rs b/crates/ui-widgets/tests/it/tile_grid/tile.rs index 75704f4d4..b0e7783b9 100644 --- a/crates/ui-widgets/tests/it/tile_grid/tile.rs +++ b/crates/ui-widgets/tests/it/tile_grid/tile.rs @@ -60,6 +60,30 @@ fn summary_card_paints_title_description_and_action() { } } +/// A summary card's description wraps onto a second line, as production's recommended-tool cards do, instead of being +/// cut with an ellipsis; the action stays below it. +#[trial] +fn a_summary_cards_long_description_wraps_instead_of_eliding() { + const DETAIL: &str = "Sticky note \u{b7} Highlight text \u{b7} Underline"; + let mut frames = Frames::new(); + let mut shapes = Vec::new(); + for _ in 0..3 { + shapes = frames.frame_shapes(|ui| { + Tile::new("Add comments").icon(craft_behavior::IconId::new("grid")).detail(DETAIL).summary_action("Use now").card().show(ui); + }); + } + let text = |wanted: &str| { + shapes.iter().find_map(|shape| match shape { + Shape::Text(text) if text.galley.job.text.starts_with(wanted) => Some((text.galley.rows.len(), text.visual_bounding_rect())), + _ => None, + }) + }; + let (lines, detail) = text("Sticky note").expect("the description is painted"); + let (_, action) = text("Use now").expect("the action is painted"); + assert!(lines >= 2, "the description wraps onto {lines} line(s) instead of being cut"); + assert!(detail.max.y <= action.min.y + 0.5, "the description {detail:?} stays above the action {action:?}"); +} + #[trial] fn the_badge_bar_leaves_out_what_does_not_fit_and_never_overlaps() { let (_, glyphs, dots) = badges(400.0);