diff --git a/crates/ui-egui/src/dialogs/graph_type.rs b/crates/ui-egui/src/dialogs/graph_type.rs index 962b569dd7..1d75fd7b97 100644 --- a/crates/ui-egui/src/dialogs/graph_type.rs +++ b/crates/ui-egui/src/dialogs/graph_type.rs @@ -1219,6 +1219,40 @@ mod tests { } } + /// A number or text row leaves the draft alone while its text is still being typed, and writes + /// the typed value once Tab commits it. + #[test] + fn typed_number_and_text_rows_reach_the_draft_only_when_committed() { + use crate::tests::panel_harness::Panel; + use craft::ui::contract::Role; + use egui::{Key, Modifiers}; + + let mut app = app_with_graph("column"); + app.run(COMMAND, json!({"columnWidth": 80, "prefix": "USD"})).unwrap(); + let mut panel = Panel::new(app, crate::tests::picks::dialogs); + panel.room(egui::vec2(900.0, 900.0)); + open(&mut panel.app()).unwrap(); + panel.frame(); + panel.click_role("Column Width", Role::SPIN_BUTTON); + panel.key(Key::A, Modifiers::COMMAND); + panel.type_text("140"); + panel.frame(); + assert_eq!(field(&panel.app(), "columnWidth"), json!(80.0), "a number being typed is not in the draft"); + panel.key(Key::Tab, Modifiers::NONE); + panel.frame(); + assert_eq!(field(&panel.app(), "columnWidth"), json!(140.0), "Tab commits the typed number"); + set(&panel.app(), PAGE, json!("valueAxis")).unwrap(); + panel.frame(); + panel.click_role("Prefix", Role::TEXT_INPUT); + panel.key(Key::A, Modifiers::COMMAND); + panel.type_text("EUR"); + panel.frame(); + assert_eq!(field(&panel.app(), "prefix"), json!("USD"), "text being typed is not in the draft"); + panel.key(Key::Tab, Modifiers::NONE); + panel.frame(); + assert_eq!(field(&panel.app(), "prefix"), json!("EUR"), "Tab commits the typed text"); + } + /// Object › Graph › Type… opens the dialog on the selected graph's options, on its Graph /// Options page; each page the type has can be shown, and Override Calculated Values of the /// right axis takes input only while that axis has a scale of its own.