Skip to content

Commit

Permalink
Merge pull request #1838 from alixander/board-label-inherit
Browse files Browse the repository at this point in the history
boards don't inherit label
  • Loading branch information
alixander authored Feb 15, 2024
2 parents e7bbda6 + 3563b15 commit 39fd268
Show file tree
Hide file tree
Showing 4 changed files with 276 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#### Improvements 🧹

- Boards no longer inherit `label` fields from parents. [#1838](https://github.com/terrastruct/d2/pull/1838)

#### Bugfixes ⛑️

- Fixes `null` being set on a nested shape not working in certain cases when connections also pointed to that shape [#1830](https://github.com/terrastruct/d2/pull/1830)
Expand Down
16 changes: 16 additions & 0 deletions d2compiler/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2991,6 +2991,22 @@ steps: {
assert.True(t, g.IsFolderOnly)
},
},
{
name: "no-inherit-label",
run: func(t *testing.T) {
g, _ := assertCompile(t, `
label: hi
steps: {
1: {
RJ
}
}
`, "")
assert.True(t, g.Root.Label.MapKey != nil)
assert.True(t, g.Steps[0].Root.Label.MapKey == nil)
},
},
{
name: "scenarios_edge_index",
run: func(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions d2ir/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,9 @@ func (c *compiler) overlay(base *Map, f *Field) {
return
}
base = base.CopyBase(f)
// Certain fields should never carry forward.
// If you give your scenario a label, you don't want all steps in a scenario to be labeled the same.
base.DeleteField("label")
OverlayMap(base, f.Map())
f.Composite = base
}
Expand Down
255 changes: 255 additions & 0 deletions testdata/d2compiler/TestCompile2/boards/no-inherit-label.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 39fd268

Please sign in to comment.