Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix setting board label with primary #2182

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading