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 elk: growing shapes with width/height set #1679

Merged
merged 5 commits into from
Oct 21, 2023
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 @@
- Grid layout now accounts for labels wider or taller than the shape and fixes default label positions for image grid cells. [#1670](https://github.com/terrastruct/d2/pull/1670)
- Fixes a panic with a spread substitution in a glob map [#1643](https://github.com/terrastruct/d2/pull/1643)
- Fixes use of `null` in `sql_table` constraints (ty @landmaj) [#1660](https://github.com/terrastruct/d2/pull/1660)
- Fixes elk growing shapes with width/height set [#1679](https://github.com/terrastruct/d2/pull/1679)
8 changes: 6 additions & 2 deletions d2layouts/d2elklayout/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,13 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
if incoming >= 2 || outgoing >= 2 {
switch g.Root.Direction.Value {
case "right", "left":
obj.Height = math.Max(obj.Height, math.Max(incoming, outgoing)*port_spacing)
if obj.Attributes.HeightAttr == nil {
obj.Height = math.Max(obj.Height, math.Max(incoming, outgoing)*port_spacing)
}
default:
obj.Width = math.Max(obj.Width, math.Max(incoming, outgoing)*port_spacing)
if obj.Attributes.WidthAttr == nil {
obj.Width = math.Max(obj.Width, math.Max(incoming, outgoing)*port_spacing)
}
}
}

Expand Down
1 change: 1 addition & 0 deletions e2etests/regression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,7 @@ cf many required: {
loadFromFile(t, "disclaimer"),
loadFromFile(t, "grid_rows_gap_bug"),
loadFromFile(t, "grid_image_label_position"),
loadFromFile(t, "glob_dimensions"),
}

runa(t, tcs)
Expand Down
48 changes: 48 additions & 0 deletions e2etests/testdata/files/glob_dimensions.d2
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
**: {
style.border-radius: 16
}

**: {
&label: end
label: ⬤
shape: circle
height: 10
width: 10
}

**: {
&label: start
label: ⬤
label.near: center-center
style.fill: black
shape: circle
height: 10
width: 10
}

**: {
&shape: diamond
label: ""
height: 20
width: 20
}

start -> Check PIN

Check PIN: {
direction: right

start -> Enter PIN
choice.shape: diamond

Enter PIN -> choice: "/check PIN"
choice -> Enter PIN: "[pin invalid]"
choice -> end: "[pin OK]"
}

Check PIN -> Search Network: "[pin OK]"
Search Network -> Ready: network found

Check PIN -> Off: power off
Search Network -> Off: power off
Ready -> Off: power off
Loading