diff --git a/crates/ui-egui/src/panels/doc_info.rs b/crates/ui-egui/src/panels/doc_info.rs index c94c3a5afb..64d9b2e101 100644 --- a/crates/ui-egui/src/panels/doc_info.rs +++ b/crates/ui-egui/src/panels/doc_info.rs @@ -45,8 +45,10 @@ pub(crate) fn row(ui: &mut Ui, label: &str, value: &str) -> bool { Row::new().fill_width().align(RowAlign::SpaceBetween).wrap(!fits).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 wider than the panel + // wraps inside it. + 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();