From 4901a806849c899efa9f978eba9b8bb5102e92a2 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Tue, 12 Aug 2025 17:55:29 +0200 Subject: [PATCH] :bug: Fix flex layout everrides are not mantained on variant switch (#7105) --- common/src/app/common/logic/libraries.cljc | 2 +- common/src/app/common/types/shape.cljc | 15 ++++++++++----- .../src/app/main/data/workspace/libraries.cljs | 4 +++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index e73b03aaee..8022e3377f 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -1952,7 +1952,7 @@ skip-operations? (or ;; If the attribute is not valid for the destiny, don't copy it - (not (cts/is-allowed-attr? attr (:type current-shape))) + (not (cts/is-allowed-switch-keep-attr? attr (:type current-shape))) ;; If the values are already equal, don't copy them (= (get previous-shape attr) (get current-shape attr)) diff --git a/common/src/app/common/types/shape.cljc b/common/src/app/common/types/shape.cljc index eaa85e40a1..0e724ecd23 100644 --- a/common/src/app/common/types/shape.cljc +++ b/common/src/app/common/types/shape.cljc @@ -413,8 +413,7 @@ (or (some :fill-image fills) (some :stroke-image strokes))) -;; Valid attributes - +;; Valid attributes for keeping on a switch (def ^:private allowed-shape-attrs #{:page-id :component-id :component-file :component-root :main-instance :remote-synced :shape-ref :touched :blocked :collapsed :locked @@ -424,17 +423,23 @@ :plugin-data}) (def ^:private allowed-shape-geom-attrs #{:x :y :width :height}) -(def ^:private allowed-shape-base-attrs #{:id :name :type :selrect :points :transform :transform-inverse :parent-id :frame-id}) +(def ^:private allowed-shape-base-attrs #{:id :name :type :selrect :points :transform + :transform-inverse :parent-id :frame-id}) (def ^:private allowed-bool-attrs #{:shapes :bool-type :content}) (def ^:private allowed-group-attrs #{:shapes}) -(def ^:private allowed-frame-attrs #{:shapes :hide-fill-on-export :show-content :hide-in-viewer}) +(def ^:private allowed-frame-attrs #{:shapes :hide-fill-on-export :show-content :hide-in-viewer + :layout :layout-flex-dir :layout-gap-type :layout-gap + :layout-align-items :layout-justify-content :layout-align-content + :layout-wrap-type :layout-padding-type :layout-padding + :layout-grid-dir :layout-justify-items :layout-grid-columns + :layout-grid-rows}) (def ^:private allowed-image-attrs #{:metadata}) (def ^:private allowed-svg-attrs #{:content}) (def ^:private allowed-path-attrs #{:content}) (def ^:private allowed-text-attrs #{:content}) (def ^:private allowed-generic-attrs (set/union allowed-shape-attrs allowed-shape-geom-attrs allowed-shape-base-attrs)) -(defn is-allowed-attr? +(defn is-allowed-switch-keep-attr? [attr type] (case type :group (or (contains? allowed-group-attrs attr) diff --git a/frontend/src/app/main/data/workspace/libraries.cljs b/frontend/src/app/main/data/workspace/libraries.cljs index b67756b0ce..82e9fd401e 100644 --- a/frontend/src/app/main/data/workspace/libraries.cljs +++ b/frontend/src/app/main/data/workspace/libraries.cljs @@ -984,7 +984,9 @@ (if keep-touched? (clv/generate-keep-touched changes new-shape shape orig-shapes page libraries ldata) [changes []]) - all-parents (into all-parents parents-of-swapped)] + all-parents (-> all-parents + (into parents-of-swapped) + (conj (:id new-shape)))] (rx/of (dwu/start-undo-transaction undo-id)