From a6a70f8d424f1138e26f4bf70a92bf883ed0482d Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 29 Nov 2026 22:08:15 +0000 Subject: [PATCH] Revisions card: the heading elides before the Accept and Reject buttons The card's heading and buttons sat in two nested rows that a narrow pane shrank evenly, so Reject was cut to an ellipsis. One row now holds the change bar, the heading link filling the room the buttons leave and eliding there, and the buttons at their whole width. Co-Authored-By: Claude Opus 5.5 --- crates/review/src/ui/revisions.rs | 33 +++++++++++++---------------- crates/review/tests/it/main.rs | 1 + crates/review/tests/it/revisions.rs | 26 +++++++++++++++++++++++ 3 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 crates/review/tests/it/revisions.rs diff --git a/crates/review/src/ui/revisions.rs b/crates/review/src/ui/revisions.rs index 60f56bf82b..e44fc0e177 100644 --- a/crates/review/src/ui/revisions.rs +++ b/crates/review/src/ui/revisions.rs @@ -4,12 +4,12 @@ use craft_behavior::{Metrics, Sense}; use craft_theme::variant::Variant; use craft_ui::buttons::{Button, Link}; use craft_ui::contract::{ - Common, Component, Container, ContainerProps, Cx, MeasureCx, NoValue, Outcome, Pad, PaintUi, Pattern, Props, Role, RowAlign, Show as _, - ShowContainer as _, Sizing, clicked, + Common, Component, Container, ContainerProps, Cx, MeasureCx, NoValue, Outcome, Pad, PaintUi, Pattern, Props, Role, Show as _, ShowContainer as _, + Sizing, clicked, }; use craft_ui::display::{Shade, Text}; use craft_ui::layout_components::{Row, Stack}; -use craft_ui::primitives::PaintShape; +use craft_ui::primitives::{PaintShape, Wrap}; use craft_ui::runtime::env::{Env, Label}; use craft_ui::style::{ComponentStyle, StyleColor, StyleCx, SurfaceKind, TypeRole}; use egui::{CornerRadius, Response, Ui, Vec2}; @@ -97,21 +97,18 @@ impl<'a> RevisionsPanel<'a> { RevisionKind::Changed => &words.changed, }; RevisionCard::new().show(ui, |ui, _| { - Row::new().fill_width().align(RowAlign::SpaceBetween).show(ui, |ui, _| { - Row::new().show(ui, |ui, _| { - ChangeBar::new(kind.clone(), revision.kind).show(ui); - if clicked(&Link::new(revision.heading.clone()).show(ui)) { - actions.push(RevisionAction::Go(index)); - } - }); - Row::new().show(ui, |ui, _| { - if clicked(&Button::new(words.accept.clone()).variant(Variant::PRIMARY).show(ui)) { - actions.push(RevisionAction::Accept(index)); - } - if clicked(&Button::new(words.reject.clone()).show(ui)) { - actions.push(RevisionAction::Reject(index)); - } - }); + // The heading takes the room the buttons leave and elides in it, so Accept and Reject stay whole. + Row::new().fill_width().show(ui, |ui, _| { + ChangeBar::new(kind.clone(), revision.kind).show(ui); + if clicked(&Link::new(revision.heading.clone()).wrap(Wrap::Elide).sizing(Sizing::FillWidth).show(ui)) { + actions.push(RevisionAction::Go(index)); + } + if clicked(&Button::new(words.accept.clone()).variant(Variant::PRIMARY).show(ui)) { + actions.push(RevisionAction::Accept(index)); + } + if clicked(&Button::new(words.reject.clone()).show(ui)) { + actions.push(RevisionAction::Reject(index)); + } }); for detail in revision.details.iter().take(DETAIL_LINES) { Text::new(words.detail_line.fill(&[("detail", detail.as_str())])).role(TypeRole::Caption).shade(Shade::Muted).show(ui); diff --git a/crates/review/tests/it/main.rs b/crates/review/tests/it/main.rs index 4de7bf55d9..f1c1181c36 100644 --- a/crates/review/tests/it/main.rs +++ b/crates/review/tests/it/main.rs @@ -5,4 +5,5 @@ pub(crate) mod balloons; pub(crate) mod collab; pub(crate) mod comments; pub(crate) mod note_popup; +pub(crate) mod revisions; pub(crate) mod signature; diff --git a/crates/review/tests/it/revisions.rs b/crates/review/tests/it/revisions.rs new file mode 100644 index 0000000000..79bac98443 --- /dev/null +++ b/crates/review/tests/it/revisions.rs @@ -0,0 +1,26 @@ +//! The Revisions panel's cards in a narrow pane. + +use craft_review::ui::RevisionsPanel; +use craft_review::{Revision, RevisionKind}; +use craft_ui::contract::Show as _; +use craft_ui::testing::{Fixture, trial}; +use egui::{Rect, Vec2}; + +/// The bounds of the card's Reject button with the panel in a room `width` wide. +fn reject_in(width: f32) -> Rect { + let changes = vec![Revision { kind: RevisionKind::Inserted, heading: "Slide inserted after 1".into(), details: vec!["What we'll cover".into()] }]; + let mut fixture = Fixture::new(move |ui| { + let _ = RevisionsPanel::new("Revisions", "Budget v2.pptx", &changes).show(ui); + }); + fixture.room(Vec2::new(width, 400.0)).settle(); + fixture.by_label("Reject").expect("the card's Reject button").rect +} + +/// A heading too long for a narrow pane elides: the card's buttons keep their whole width. +#[trial] +fn a_long_heading_leaves_the_card_buttons_whole() { + let wide = reject_in(900.0); + let narrow = reject_in(220.0); + assert!(narrow.width() >= wide.width() - 0.5, "Reject keeps its width: {narrow:?} against {wide:?}"); + assert!(narrow.right() <= 220.5, "Reject stays inside the pane: {narrow:?}"); +}