From 20b5b7f6e46e7626d06398fc477024dd65a137c5 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Fri, 27 Jun 2025 12:23:54 +0200 Subject: [PATCH] :bug: Fix variant switch in another page (#6802) --- common/src/app/common/logic/variants.cljc | 7 +++++-- common/src/app/common/types/file.cljc | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/common/src/app/common/logic/variants.cljc b/common/src/app/common/logic/variants.cljc index fd6ca11db0..0843983c30 100644 --- a/common/src/app/common/logic/variants.cljc +++ b/common/src/app/common/logic/variants.cljc @@ -91,11 +91,14 @@ ;; shape on the main component orig-ref-shape (ctf/find-ref-shape nil container libraries original-shape) + orig-ref-objects (-> (ctf/get-component-container-from-head orig-ref-shape libraries) + :objects) + ;; Adds a :shape-path attribute to the children of the orig-ref-shape, ;; that contains the type of its ancestors and its name o-ref-shapes-wp (add-unique-path - (reverse (cfh/get-children-with-self objects (:id orig-ref-shape))) - objects + (reverse (cfh/get-children-with-self orig-ref-objects (:id orig-ref-shape))) + orig-ref-objects (:id orig-ref-shape)) ;; Creates a map to quickly find a child of the orig-ref-shape by its shape-path diff --git a/common/src/app/common/types/file.cljc b/common/src/app/common/types/file.cljc index f4ecbd4acc..fafa4b7226 100644 --- a/common/src/app/common/types/file.cljc +++ b/common/src/app/common/types/file.cljc @@ -242,6 +242,13 @@ (cfh/make-container component-page :page)) (cfh/make-container component :component))) +(defn get-component-container-from-head + [instance-head libraries & {:keys [include-deleted?] :or {include-deleted? true}}] + (let [library-data (-> (get-component-library libraries instance-head) + :data) + component (ctkl/get-component library-data (:component-id instance-head) include-deleted?)] + (get-component-container library-data component))) + (defn get-component-root "Retrieve the root shape of the component." [file-data component]