Skip to content

Commit

Permalink
Merge pull request #2182 from alixander/board-label
Browse files Browse the repository at this point in the history
fix setting board label with primary
  • Loading branch information
alixander authored Oct 30, 2024
2 parents b2cf9d3 + 2546618 commit 3d39254
Show file tree
Hide file tree
Showing 5 changed files with 543 additions and 1 deletion.
1 change: 1 addition & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
#### Bugfixes ⛑️

- Render: fixes edge case of a 3d shape with outside label being cut off [#2132](https://github.com/terrastruct/d2/pull/2132)
- Composition: labels for boards set with shorthand `x: y` was not applied [#2182](https://github.com/terrastruct/d2/pull/2182)
3 changes: 3 additions & 0 deletions d2compiler/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ func (c *compiler) compileBoardsField(g *d2graph.Graph, ir *d2ir.Map, fieldName
g2.BaseAST = findFieldAST(g.BaseAST, f)
}
c.compileBoard(g2, m)
if f.Primary() != nil {
c.compileLabel(&g2.Root.Attributes, f)
}
g2.Name = f.Name
switch fieldName {
case "layers":
Expand Down
18 changes: 18 additions & 0 deletions d2compiler/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3511,6 +3511,24 @@ steps: {
assert.True(t, g.IsFolderOnly)
},
},
{
name: "board-label-primary",
run: func(t *testing.T) {
g, _ := assertCompile(t, `hi
layers: {
1: one {
RJ
}
2: {
label: two
RJ
}
}
`, "")
assert.Equal(t, "one", g.Layers[0].Root.Label.Value)
assert.Equal(t, "two", g.Layers[1].Root.Label.Value)
},
},
{
name: "no-inherit-label",
run: func(t *testing.T) {
Expand Down
Loading

0 comments on commit 3d39254

Please sign in to comment.