diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index c5634969a..c559be619 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -603,6 +603,23 @@ (generate-detach-instance changes container shape-id)))) changes))) +(defn- find-main-container + "Find the container that has the main shape." + [container-inst shape-inst shape-main library component] + (loop [shape-inst' shape-inst + component' component] + (let [container (ctf/get-component-container library component')] ; TODO: this won't work if some intermediate component is in a different library + (if (some? (ctn/get-shape container (:id shape-main))) ; for this to work we need to have access to the libraries list here + container + (let [parent (ctn/get-shape container-inst (:parent-id shape-inst')) + shape-inst' (ctn/get-head-shape (:objects container-inst) parent) + component' (or (ctkl/get-component library (:component-id shape-inst')) + (ctkl/get-deleted-component library (:component-id shape-inst')))] + (if (some? component) + (recur shape-inst' + component') + nil)))))) + (defn- generate-sync-shape-direct-recursive [changes container shape-inst component library shape-main root-inst root-main reset? initial-root? redirect-shaperef components-v2] (log/debug :msg "Sync shape direct recursive" @@ -639,7 +656,7 @@ set-remote-synced? (change-remote-synced shape-inst container true)) - component-container (ctf/get-component-container library component) + component-container (find-main-container container shape-inst shape-main library component) children-inst (vec (ctn/get-direct-children container shape-inst)) children-main (vec (ctn/get-direct-children component-container shape-main))