diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index ebeeb0816..5ffa7954b 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -968,16 +968,15 @@ func (obj *Object) GetDefaultSize(mtexts []*d2target.MText, ruler *textmeasure.R return &dims, nil } -func (obj *Object) IsInsideNearContainer() bool { +func (obj *Object) OuterNearContainer() *Object { temp := obj for temp != nil { - fmt.Println(temp.ID) if temp.Attributes.NearKey != nil { - return true + return temp } temp = temp.Parent } - return false + return nil } type Edge struct { diff --git a/d2layouts/d2near/layout.go b/d2layouts/d2near/layout.go index 5b86b892e..b9d3fcbfa 100644 --- a/d2layouts/d2near/layout.go +++ b/d2layouts/d2near/layout.go @@ -225,7 +225,7 @@ func boundingBox(g *d2graph.Graph) (tl, br *geo.Point) { y2 = math.Max(y2, obj.TopLeft.Y+obj.Height) } } else { - if obj.IsInsideNearContainer() { + if obj.OuterNearContainer() != nil { continue } x1 = math.Min(x1, obj.TopLeft.X)