From db9e397531c798fdd75c56084804ff06490ab86e Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Mon, 21 Apr 2025 09:02:29 +0200 Subject: [PATCH] :bug: Fix variant from a shared lib doesnt't show props --- common/src/app/common/files/variant.cljc | 1 + .../sidebar/options/menus/component.cljs | 19 +++++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/common/src/app/common/files/variant.cljc b/common/src/app/common/files/variant.cljc index 86c0e82836..e901fd19ef 100644 --- a/common/src/app/common/files/variant.cljc +++ b/common/src/app/common/files/variant.cljc @@ -15,6 +15,7 @@ (defn find-variant-components "Find a list of the components thet belongs to this variant-id" [data objects variant-id] + ;; We can't simply filter components, because we need to maintain the order (->> (dm/get-in objects [variant-id :shapes]) (map #(dm/get-in objects [% :component-id])) (map #(ctcl/get-component data % true)) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs index 5752498c13..315372ebf8 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs @@ -234,27 +234,27 @@ (mf/defc component-variant* - [{:keys [component shape data page-id]}] + [{:keys [component shape data]}] (let [id-component (:id component) properties (:variant-properties component) variant-id (:variant-id component) - objects (-> (dsh/get-page data page-id) + objects (-> (dsh/get-page data (:main-instance-page component)) (get :objects)) - related-components (cfv/find-variant-components data objects variant-id) + variant-components (cfv/find-variant-components data objects variant-id) flat-comps ;; Get a list like [{:id 0 :prop1 "v1" :prop2 "v2"} {:id 1, :prop1 "v3" :prop2 "v4"}] (map (fn [{:keys [id variant-properties]}] (into {:id id} (map (fn [{:keys [name value]}] [(keyword name) value]) variant-properties))) - related-components) + variant-components) get-options (mf/use-fn - (mf/deps related-components) + (mf/deps variant-components) (fn [prop-name] - (->> related-components + (->> variant-components (mapcat (fn [component] (map :value (filter #(= (:name %) prop-name) (:variant-properties component))))) @@ -610,11 +610,10 @@ {::mf/props :obj} [{:keys [shapes swap-opened?]}] (let [current-file-id (mf/use-ctx ctx/current-file-id) - current-page-id (mf/use-ctx ctx/current-page-id) libraries (deref refs/files) current-file (get libraries current-file-id) - data (get current-file :data) + state* (mf/use-state #(do {:show-content true @@ -637,7 +636,7 @@ current-file libraries {:include-deleted? true}) - + data (dm/get-in libraries [(:component-file shape) :data]) variants? (features/use-feature "variants/v1") is-variant? (when variants? (ctk/is-variant? component)) main-instance? (ctk/main-instance? shape) @@ -750,7 +749,7 @@ [:& component-annotation {:id id :shape shape :component component :rerender-fn rerender-fn}]) (when (and is-variant? (not swap-opened?) (not multi)) - [:> component-variant* {:component component :shape shape :data data :page-id current-page-id}]) + [:> component-variant* {:component component :shape shape :data data}]) (when (dbg/enabled? :display-touched) [:div ":touched " (str (:touched shape))])])])))