Skip to content

Commit 39fd268

Browse files
authored
Merge pull request #1838 from alixander/board-label-inherit
boards don't inherit label
2 parents e7bbda6 + 3563b15 commit 39fd268

File tree

4 files changed

+276
-0
lines changed

4 files changed

+276
-0
lines changed

ci/release/changelogs/next.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#### Improvements 🧹
66

7+
- Boards no longer inherit `label` fields from parents. [#1838](https://github.com/terrastruct/d2/pull/1838)
8+
79
#### Bugfixes ⛑️
810

911
- 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)

d2compiler/compile_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -2991,6 +2991,22 @@ steps: {
29912991
assert.True(t, g.IsFolderOnly)
29922992
},
29932993
},
2994+
{
2995+
name: "no-inherit-label",
2996+
run: func(t *testing.T) {
2997+
g, _ := assertCompile(t, `
2998+
label: hi
2999+
3000+
steps: {
3001+
1: {
3002+
RJ
3003+
}
3004+
}
3005+
`, "")
3006+
assert.True(t, g.Root.Label.MapKey != nil)
3007+
assert.True(t, g.Steps[0].Root.Label.MapKey == nil)
3008+
},
3009+
},
29943010
{
29953011
name: "scenarios_edge_index",
29963012
run: func(t *testing.T) {

d2ir/compile.go

+3
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ func (c *compiler) overlay(base *Map, f *Field) {
361361
return
362362
}
363363
base = base.CopyBase(f)
364+
// Certain fields should never carry forward.
365+
// If you give your scenario a label, you don't want all steps in a scenario to be labeled the same.
366+
base.DeleteField("label")
364367
OverlayMap(base, f.Map())
365368
f.Composite = base
366369
}

testdata/d2compiler/TestCompile2/boards/no-inherit-label.exp.json

+255
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)