mirror of
https://github.com/penpot/penpot.git
synced 2026-09-12 15:09:38 +00:00
🐛 Fix flex layout everrides are not mantained on variant switch (#7105)
This commit is contained in:
parent
03b5d44a7c
commit
4901a80684
@ -1952,7 +1952,7 @@
|
|||||||
skip-operations?
|
skip-operations?
|
||||||
(or
|
(or
|
||||||
;; If the attribute is not valid for the destiny, don't copy it
|
;; 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
|
;; If the values are already equal, don't copy them
|
||||||
(= (get previous-shape attr) (get current-shape attr))
|
(= (get previous-shape attr) (get current-shape attr))
|
||||||
|
|||||||
@ -413,8 +413,7 @@
|
|||||||
(or (some :fill-image fills)
|
(or (some :fill-image fills)
|
||||||
(some :stroke-image strokes)))
|
(some :stroke-image strokes)))
|
||||||
|
|
||||||
;; Valid attributes
|
;; Valid attributes for keeping on a switch
|
||||||
|
|
||||||
(def ^:private allowed-shape-attrs
|
(def ^:private allowed-shape-attrs
|
||||||
#{:page-id :component-id :component-file :component-root :main-instance
|
#{:page-id :component-id :component-file :component-root :main-instance
|
||||||
:remote-synced :shape-ref :touched :blocked :collapsed :locked
|
:remote-synced :shape-ref :touched :blocked :collapsed :locked
|
||||||
@ -424,17 +423,23 @@
|
|||||||
:plugin-data})
|
:plugin-data})
|
||||||
|
|
||||||
(def ^:private allowed-shape-geom-attrs #{:x :y :width :height})
|
(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-bool-attrs #{:shapes :bool-type :content})
|
||||||
(def ^:private allowed-group-attrs #{:shapes})
|
(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-image-attrs #{:metadata})
|
||||||
(def ^:private allowed-svg-attrs #{:content})
|
(def ^:private allowed-svg-attrs #{:content})
|
||||||
(def ^:private allowed-path-attrs #{:content})
|
(def ^:private allowed-path-attrs #{:content})
|
||||||
(def ^:private allowed-text-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))
|
(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]
|
[attr type]
|
||||||
(case type
|
(case type
|
||||||
:group (or (contains? allowed-group-attrs attr)
|
:group (or (contains? allowed-group-attrs attr)
|
||||||
|
|||||||
@ -984,7 +984,9 @@
|
|||||||
(if keep-touched?
|
(if keep-touched?
|
||||||
(clv/generate-keep-touched changes new-shape shape orig-shapes page libraries ldata)
|
(clv/generate-keep-touched changes new-shape shape orig-shapes page libraries ldata)
|
||||||
[changes []])
|
[changes []])
|
||||||
all-parents (into all-parents parents-of-swapped)]
|
all-parents (-> all-parents
|
||||||
|
(into parents-of-swapped)
|
||||||
|
(conj (:id new-shape)))]
|
||||||
|
|
||||||
(rx/of
|
(rx/of
|
||||||
(dwu/start-undo-transaction undo-id)
|
(dwu/start-undo-transaction undo-id)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user