diff --git a/common/src/app/common/files/helpers.cljc b/common/src/app/common/files/helpers.cljc index ff526e2bda..296d4da83c 100644 --- a/common/src/app/common/files/helpers.cljc +++ b/common/src/app/common/files/helpers.cljc @@ -148,6 +148,15 @@ [objects id] (mapv (d/getf objects) (get-children-ids-with-self objects id))) +(defn get-child + "Return the child of the given object with the given id (allow that the + id may point to the object itself)." + [objects id child-id] + (let [shape (get objects id)] + (if (= id child-id) + shape + (some #(get-child objects % child-id) (:shapes shape))))) + (defn get-parent "Retrieve the parent for the shape-id (if exists)" [objects id] diff --git a/common/src/app/common/types/file.cljc b/common/src/app/common/types/file.cljc index fc8281386c..3f8e7b3bde 100644 --- a/common/src/app/common/types/file.cljc +++ b/common/src/app/common/types/file.cljc @@ -168,7 +168,9 @@ (if (and components-v2 (not (:deleted component))) (let [component-page (get-component-page file-data component)] (when component-page - (ctn/get-shape component-page shape-id))) + (cfh/get-child (:objects component-page) + (:main-instance-id component) + shape-id))) (dm/get-in component [:objects shape-id])))) (defn get-ref-shape