From 86de2cd4146260cf00e7fcd6030f7da7c86d11f9 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Mon, 25 Sep 2023 15:38:22 -0700 Subject: [PATCH] fix --- d2layouts/d2layouts.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/d2layouts/d2layouts.go b/d2layouts/d2layouts.go index dcd3b4ac3..dddba2d44 100644 --- a/d2layouts/d2layouts.go +++ b/d2layouts/d2layouts.go @@ -101,12 +101,27 @@ func LayoutNested(ctx context.Context, g *d2graph.Graph, graphInfo GraphInfo, co // if we are in a grid diagram, and our children have descendants // we need to run layout on them first, even if they are not special diagram types nestedGraph := ExtractSubgraph(curr, true) + id := curr.AbsID() err := LayoutNested(ctx, nestedGraph, GraphInfo{}, coreLayout) if err != nil { return err } InjectNested(g.Root, nestedGraph, false) restoreOrder() + + // need to update curr *Object incase layout changed it + var obj *d2graph.Object + for _, o := range g.Objects { + if o.AbsID() == id { + obj = o + break + } + } + if obj == nil { + return fmt.Errorf("could not find object %#v after layout", id) + } + curr = obj + dx := -curr.TopLeft.X dy := -curr.TopLeft.Y for _, o := range nestedGraph.Objects {