0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-22 06:46:40 -05:00

🐛 Fix propagation of changes with nested components

This commit is contained in:
Andrés Moya 2023-12-13 18:23:21 +01:00
parent 02986f81bd
commit fd5fd87360

View file

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