diff --git a/crates/engine-core/src/cmd/frame_cmds.rs b/crates/engine-core/src/cmd/frame_cmds.rs index cf91c38b67..3be1a9f73d 100644 --- a/crates/engine-core/src/cmd/frame_cmds.rs +++ b/crates/engine-core/src/cmd/frame_cmds.rs @@ -162,8 +162,9 @@ fn frame_from_layers(s: &mut Session, p: &Value) -> Result { .unwrap_or(st.doc.bounds()); let f = geometry(&json!({"x":bounds.x0,"y":bounds.y0,"width":bounds.width(),"height":bounds.height()}))?; // The frame is the next "Frame N", as an empty frame is, unless the caller names it (#17329). + // A blank name is no name, as it is to the grouping; one that is not text is left for it to refuse. let mut grouping = p.clone(); - if p.get("name").is_none_or(Value::is_null) { + if p.get("name").is_none_or(|n| n.is_null() || n.as_str().is_some_and(|n| n.trim().is_empty())) { grouping["name"] = json!(st.doc.next_layer_name("Frame")); } let journal = s.journal.len(); diff --git a/crates/engine-core/src/cmd/frame_cmds/from_layers_names_tests.rs b/crates/engine-core/src/cmd/frame_cmds/from_layers_names_tests.rs index f5e7f760de..c2e2553ebf 100644 --- a/crates/engine-core/src/cmd/frame_cmds/from_layers_names_tests.rs +++ b/crates/engine-core/src/cmd/frame_cmds/from_layers_names_tests.rs @@ -64,6 +64,19 @@ fn convert_to_frame_does_not_take_a_frame_number() { assert_eq!(frame_from(&mut s, &[red]), named("Frame 1", "Red")); } +#[test] +fn a_blank_name_takes_the_frame_number_as_no_name_does() { + for blank in [json!(""), json!(" "), Value::Null] { + let (mut s, red, _) = session(); + let r = s.execute("layer.new.frameFromLayers", json!({"layer": red.0, "name": blank})).unwrap(); + let g = s.active().unwrap().doc.layer(LayerId(r["layer"].as_u64().unwrap())).unwrap(); + assert_eq!(g.name, "Frame 1", "name {blank:?}"); + } + // A name that is not text is still refused, not replaced. + let (mut s, red, _) = session(); + assert!(s.execute("layer.new.frameFromLayers", json!({"layer": red.0, "name": 7})).is_err()); +} + #[test] fn the_step_is_add_frame_to_layers_and_a_given_name_wins() { let (mut s, red, _) = session();