diff --git a/crates/op-orchestrator/src/role_post_pass.rs b/crates/op-orchestrator/src/role_post_pass.rs index f06a42c8c..0a7bd17cc 100644 --- a/crates/op-orchestrator/src/role_post_pass.rs +++ b/crates/op-orchestrator/src/role_post_pass.rs @@ -439,7 +439,10 @@ fn size_number(node: &Value, key: &str) -> f64 { } /// Equalize a row of fixed-width card frames to `fill_container` so they stretch -/// evenly (port of `equalizeCardRow`). Pure property fix — taffy then lays out. +/// evenly (port of `equalizeCardRow` AND the near-identical +/// `equalizeHorizontalSiblings` in design-canvas-ops.ts — the dashboard 等宽 +/// pass; the badge/pill/tag exclusions come from the latter). Pure property fix +/// — taffy then lays out. fn equalize_card_row(node: &mut Value) { if node.get("layout").and_then(Value::as_str) != Some("horizontal") { return; @@ -458,7 +461,14 @@ fn equalize_card_row(node: &mut Value) { .enumerate() .filter(|(_, c)| { c.get("type").and_then(Value::as_str) == Some("frame") - && !matches!(role_of(c), Some("divider") | Some("phone-mockup")) + && !matches!( + role_of(c), + Some("divider") + | Some("phone-mockup") + | Some("badge") + | Some("pill") + | Some("tag") + ) && size_number(c, "height") > 88.0 }) .map(|(i, _)| i) diff --git a/crates/op-orchestrator/src/role_post_pass_tests.rs b/crates/op-orchestrator/src/role_post_pass_tests.rs index a8f6fe8c7..044102e5b 100644 --- a/crates/op-orchestrator/src/role_post_pass_tests.rs +++ b/crates/op-orchestrator/src/role_post_pass_tests.rs @@ -223,6 +223,26 @@ fn card_row_left_alone_when_widths_similar() { assert_eq!(row["children"][0]["width"], json!(200)); } +#[test] +fn badge_pill_tag_rows_are_not_equalized() { + // The dashboard-pass (equalizeHorizontalSiblings) excludes badge/pill/tag, + // so a row of those keeps its widths even with a low width ratio. + for role in ["badge", "pill", "tag"] { + let mut row = json!({ + "type":"frame","layout":"horizontal","children":[ + {"type":"frame","role":role,"width":240,"height":200,"children":[]}, + {"type":"frame","role":role,"width":120,"height":210,"children":[]} + ] + }); + equalize_card_row(&mut row); + assert_eq!( + row["children"][0]["width"], + json!(240), + "{role} row must not be equalized" + ); + } +} + #[test] fn form_inputs_promoted_when_fill_sibling_present() { let mut form = json!({