0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-28 15:41:25 -05:00

🐛 Fix problem with fit-content on coponent copies

This commit is contained in:
alonso.torres 2024-03-22 10:46:06 +01:00
parent 3d6eb9d4bb
commit bf5d95e069

View file

@ -311,6 +311,19 @@
[new-root-shape (map remap-frame-id new-shapes) updated-shapes]))
(defn remove-swap-keep-attrs
"Remove flex children properties except the fit-content for flex layouts. These are properties
that we don't have to propagate to copies but will be respected when swapping components"
[shape]
(let [layout-item-h-sizing (when (and (ctl/flex-layout? shape) (ctl/auto-width? shape)) :auto)
layout-item-v-sizing (when (and (ctl/flex-layout? shape) (ctl/auto-height? shape)) :auto)]
(-> shape
(d/without-keys ctk/swap-keep-attrs)
(cond-> (some? layout-item-h-sizing)
(assoc :layout-item-h-sizing layout-item-h-sizing))
(cond-> (some? layout-item-v-sizing)
(assoc :layout-item-v-sizing layout-item-v-sizing)))))
(defn make-component-instance
"Generate a new instance of the component inside the given container.
@ -331,7 +344,7 @@
(-> (get-shape component-page (:main-instance-id component))
(assoc :parent-id nil) ;; On v2 we force parent-id to nil in order to behave like v1
(assoc :frame-id uuid/zero)
(d/without-keys ctk/swap-keep-attrs))
(remove-swap-keep-attrs))
(get-shape component (:id component)))
orig-pos (gpt/point (:x component-shape) (:y component-shape))