diff --git a/crates/ui-egui/src/panels/doc_info.rs b/crates/ui-egui/src/panels/doc_info.rs index ad8b8ce9f7..c94c3a5afb 100644 --- a/crates/ui-egui/src/panels/doc_info.rs +++ b/crates/ui-egui/src/panels/doc_info.rs @@ -35,8 +35,14 @@ pub struct DocInfoView { /// the second or third click of a double or triple click. pub(crate) fn row(ui: &mut Ui, label: &str, value: &str) -> bool { let mut clicked = false; - // A wrapping row places its children as `Start` does, so the row does not wrap and the value stands at its end. - Row::new().fill_width().align(RowAlign::SpaceBetween).show(ui, |ui, _| { + // A row whose label and value fit on one line keeps the value at its end. A wrapping row places its children as + // `Start` does, so the row wraps only when the two do not fit, as in a narrow panel or a longer translation. + let width = |text: &str| { + let font = egui::TextStyle::Body.resolve(ui.style()); + ui.painter().layout_no_wrap(text.to_string(), font, egui::Color32::WHITE).size().x + }; + let fits = width(label) + width(value) + 2.0 * ui.spacing().item_spacing.x <= ui.available_width(); + 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.