diff --git a/crates/ui-egui/src/dialogs/option_form.rs b/crates/ui-egui/src/dialogs/option_form.rs index 7b127c08ef..fde3f40932 100644 --- a/crates/ui-egui/src/dialogs/option_form.rs +++ b/crates/ui-egui/src/dialogs/option_form.rs @@ -507,6 +507,15 @@ pub(super) mod tests { crate::toolbar::open_options(&mut panel.app(), "livePaintBucket").unwrap(); panel.frame(); assert_eq!(fields(&panel.app()), before); + panel.click_role("Width", Role::SPIN_BUTTON); + panel.key(Key::A, Modifiers::COMMAND); + panel.type_text("9"); + assert_eq!(fields(&panel.app())["width"], 9.0, "typing proposes the width"); + panel.type_text("x"); + panel.key(Key::Tab, Modifiers::NONE); + panel.frame(); + assert!(is_open(&panel.app()), "leaving the field keeps the dialog open"); + assert_eq!(fields(&panel.app()), before, "leaving the field on text that is not a number restores the opening width"); if commit { panel.click_role("Width", Role::SPIN_BUTTON); panel.key(Key::A, Modifiers::COMMAND); @@ -530,7 +539,7 @@ pub(super) mod tests { /// Normal Gap Options supplies numeric points. This hosted row fixture separately checks /// the nullable length helper's contract, including restoring an empty opening value. #[test] - fn a_nullable_length_row_restores_null_on_escape() { + fn a_nullable_length_row_restores_null_when_its_typing_is_canceled() { static NULL_LENGTH: OptionSpec = OptionSpec { key: "nullableLengthTest", title: || "Nullable Length".into(), @@ -555,6 +564,15 @@ pub(super) mod tests { open(&mut panel.app(), &NULL_LENGTH, Map::from_iter([("length".into(), Value::Null)]), Value::Null).unwrap(); panel.frame(); assert_eq!(fields(&panel.app())["length"], Value::Null); + panel.click_role("Length", Role::SPIN_BUTTON); + panel.key(Key::A, Modifiers::COMMAND); + panel.type_text("9 pt"); + assert_eq!(fields(&panel.app())["length"], 9.0); + panel.type_text("x"); + panel.key(Key::Tab, Modifiers::NONE); + panel.frame(); + assert!(is_open(&panel.app()), "leaving the field keeps the dialog open"); + assert_eq!(fields(&panel.app())["length"], Value::Null, "leaving the field on text that is not a length restores null"); } /// Whether `a` and `b` are the same value, numbers by their value.