diff --git a/crates/ui-egui/src/addons/typetools/numbers.rs b/crates/ui-egui/src/addons/typetools/numbers.rs index 68351ad068..250e6788a6 100644 --- a/crates/ui-egui/src/addons/typetools/numbers.rs +++ b/crates/ui-egui/src/addons/typetools/numbers.rs @@ -84,7 +84,9 @@ pub(crate) fn open(app: &mut VectorcraftApp) -> Result { Param::section(tl!("Zeros")), Param::new("leadingZeros", tl!("Leading Zeros"), ParamKind::bool(true)), Param::new("fixedDigits", tl!("Fixed Number of Digits"), ParamKind::bool(false)).enabled_when("leadingZeros", FieldValue::Bool(true)), - Param::new("digits", tl!("Digits:"), ParamKind::int(Some(1), Some(30), 3)).enabled_when("fixedDigits", FieldValue::Bool(true)), + Param::new("digits", tl!("Digits:"), ParamKind::int(Some(1), Some(30), 3)) + .enabled_when("fixedDigits", FieldValue::Bool(true)) + .and_enabled_when_in("leadingZeros", [FieldValue::Bool(true)]), Param::new("trailingZeros", tl!("Trailing Zeros"), ParamKind::bool(false)), Param::new("order", tl!("Order:"), radio(&ORDERS)).enabled_when("shuffle", FieldValue::Bool(false)), Param::new("replace", tl!("Replace:"), radio(&REPLACES)), diff --git a/crates/ui-egui/src/addons/typetools/numbers/tests.rs b/crates/ui-egui/src/addons/typetools/numbers/tests.rs index 79acbf8ef1..bb9f3bcfca 100644 --- a/crates/ui-egui/src/addons/typetools/numbers/tests.rs +++ b/crates/ui-egui/src/addons/typetools/numbers/tests.rs @@ -25,6 +25,24 @@ fn texts(app: &VectorcraftApp, ids: &[u64]) -> Vec { .collect() } +/// Digits takes input only while Leading Zeros and Fixed Number of Digits are both on, since the +/// command gets `digits` only then. +#[test] +fn digits_takes_input_only_with_leading_zeros() { + let (app, _) = app(); + let mut panel = crate::tests::panel_harness::Panel::new(app, crate::tests::picks::dialogs); + open_item(&mut panel.app(), "Type Tools", "Make Numbers Sequence…"); + panel.frame(); + let dialog = dialog_id(&panel.app()); + set(&panel.app(), dialog, "fixedDigits", json!(true)); + panel.frame(); + assert!(panel.enabled("Digits")); + set(&panel.app(), dialog, "leadingZeros", json!(false)); + panel.frame(); + assert!(read(&panel.app(), dialog, super::params).get("digits").is_none()); + assert!(!panel.enabled("Digits"), "with Leading Zeros off the command gets no digits"); +} + /// The dialog's fields reach the command: an end and fixed digits only when turned on, and OK /// numbers the objects as one undo step. #[test] diff --git a/docs/mcp.md b/docs/mcp.md index 30ac0bfb82..61ac378b0a 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -18832,7 +18832,8 @@ script. | `removeUnused` | false; true needs `end` | → `{count (objects changed), ids (numbered, in order), removed}`. Make Numbers Sequence… opens a dialog (`ui.menuDialog -{command}`, dialog key `addon.type.numbers`) whose fields are the command's parameters, with Preview. +{command}`, dialog key `addon.type.numbers`) whose fields are the command's parameters, with Preview. Its Digits field takes input only while Leading Zeros +and Fixed Number of Digits are both on. ```json {"name":"run_command","arguments":{"command":"addon.type.numbers","params":{"start":1,"order":"rows"}}}