From 97ee32bcf7be994e3bc43df01ba9abc2441b8a93 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 15:33:46 -0800 Subject: [PATCH] Document Info: a value wider than the panel wraps inside it A row moves its value under the label when the two do not fit on one line, but a value wider than the whole panel, such as a long document name, still ran past the panel's edge. The value now shows as multiline selectable text, so it wraps inside the panel. Short values still stand at the row end. --- crates/ui-egui/src/panels/doc_info.rs | 6 ++++-- .../ui-egui/src/panels/tests_panel_spacing.rs | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/panels/doc_info.rs b/crates/ui-egui/src/panels/doc_info.rs index ad8b8ce9f7..45c306f05a 100644 --- a/crates/ui-egui/src/panels/doc_info.rs +++ b/crates/ui-egui/src/panels/doc_info.rs @@ -39,8 +39,10 @@ pub(crate) fn row(ui: &mut Ui, label: &str, value: &str) -> bool { Row::new().fill_width().align(RowAlign::SpaceBetween).show(ui, |ui, _| { Text::new(label.to_string()).shade(Shade::Muted).show(ui); // The value can be selected and copied, and a click copies all of it (#8432). A drag selects - // and a Shift-click extends the selection, so neither copies. - clicked = copy_value(ui, label, value, false); + // and a Shift-click extends the selection, so neither copies. A value too long to fit beside + // its label wraps inside the panel. + let shown = SelectableText::new(label.to_string(), value).multiline().show(ui); + clicked = copy_shown(ui, &shown, value); }); clicked } diff --git a/crates/ui-egui/src/panels/tests_panel_spacing.rs b/crates/ui-egui/src/panels/tests_panel_spacing.rs index d93eefca3a..621c92817d 100644 --- a/crates/ui-egui/src/panels/tests_panel_spacing.rs +++ b/crates/ui-egui/src/panels/tests_panel_spacing.rs @@ -33,6 +33,24 @@ fn document_info_values_end_at_one_edge() { assert!(value.left() > label.right() + label.width(), "the value {value:?} sits against its label {label:?}"); } +#[test] +fn a_long_document_info_value_wraps_inside_a_narrow_panel() { + let name = "A document name long enough to run past a narrow panel"; + let mut app = crate::testing::windowed(VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default())); + run(&mut app, "file.new", json!({"width": 200, "height": 200, "name": name})); + let mut panel = Panel::new(app, doc_info::show); + let width = 160.0; + panel.room(egui::vec2(width, ROOM.y)); + panel.frame(); + panel.frame(); + let texts = panel.texts(); + let runs: Vec = texts.iter().filter(|(t, _)| t.starts_with("A document")).map(|(_, r)| *r).collect(); + assert!(!runs.is_empty(), "no run of the name in {texts:?}"); + for r in &runs { + assert!(r.right() <= width + 0.5, "the name ends at {}, past the panel's {width}: {texts:?}", r.right()); + } +} + #[test] fn info_paints_stand_a_section_apart_from_the_numbers() { let mut app = app_with_rect();