From d1fcf69b7bbab9f2329e7295956e8a88bb8c0773 Mon Sep 17 00:00:00 2001 From: MarekSpodBiedry <73122968+MarekSpodBiedry@users.noreply.github.com> Date: Thu, 15 Oct 2026 17:17:30 +0200 Subject: [PATCH] Keep Mixed line height when Enter is pressed without typing (#439) --- crates/ui-egui/src/typography.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/typography.rs b/crates/ui-egui/src/typography.rs index 56854f27..45f38b95 100644 --- a/crates/ui-egui/src/typography.rs +++ b/crates/ui-egui/src/typography.rs @@ -1017,9 +1017,13 @@ fn lead_field(ui: &mut Ui, id: Id, glyph: LeadGlyph, value: &str, width: f32, ti } /// "Auto", "24", "150%" → the `lineHeight` value. A bare number keeps the current unit when it is -/// a percentage, else means pixels. +/// a percentage, else means pixels. Empty text means Auto, except on a Mixed field (`cur` is +/// `None`), where nothing typed is an untouched field and commits nothing. pub(crate) fn parse_line_height(s: &str, cur: Option) -> Option { let s = s.trim(); + if s.is_empty() && cur.is_none() { + return None; + } if s.is_empty() || s.eq_ignore_ascii_case("auto") { return Some(json!("auto")); } @@ -1200,6 +1204,9 @@ mod tests { assert_eq!(parse_line_height("130", Some(LineHeight::Percent(120.0))), Some(json!("130%"))); assert_eq!(parse_line_height("-5", Some(LineHeight::Pixels(10.0))), Some(json!(0.0))); assert_eq!(parse_line_height("abc", None), None); + // Enter on an untouched Mixed field commits nothing; typing Auto still does. + assert_eq!(parse_line_height("", None), None); + assert_eq!(parse_line_height(" ", None), None); assert_eq!(parse_letter_spacing("2%", None), Some(json!("2%"))); assert_eq!(parse_letter_spacing("1.5px", None), Some(json!(1.5))); assert_eq!(parse_letter_spacing("-1", None), Some(json!("-1%")));