0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-06 04:41:57 -05:00

🐛 Fix problem when creating layouts

This commit is contained in:
Alonso Torres 2025-03-04 11:04:26 +01:00 committed by GitHub
parent 8d4b023d61
commit 856e2be1ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View file

@ -1666,3 +1666,12 @@
(-> cells
(d/update-when id d/patch-object (get-data target-cells id))))
source-cells))))))
(defn toggle-fix-if-auto
"Changes the sizing to fix if it's fill"
[shape]
(cond-> shape
(= (:layout-item-h-sizing shape) :fill)
(assoc :layout-item-h-sizing :fix)
(= (:layout-item-v-sizing shape) :fill)
(assoc :layout-item-v-sizing :fix)))

View file

@ -194,7 +194,7 @@
(cl/remove-all-fills [new-shape-id] {:color clr/black :opacity 1})
(create-layout-from-id new-shape-id type)
(dwsh/update-shapes [new-shape-id] #(assoc % :layout-item-h-sizing :auto :layout-item-v-sizing :auto))
(dwsh/update-shapes selected #(assoc % :layout-item-h-sizing :fix :layout-item-v-sizing :fix))
(dwsh/update-shapes selected ctl/toggle-fix-if-auto)
(dwsh/delete-shapes page-id selected)
(ptk/data-event :layout/update {:ids [new-shape-id]})
(dwu/commit-undo-transaction undo-id)))
@ -205,7 +205,7 @@
(cl/remove-all-fills [new-shape-id] {:color clr/black :opacity 1})
(create-layout-from-id new-shape-id type)
(dwsh/update-shapes [new-shape-id] #(assoc % :layout-item-h-sizing :auto :layout-item-v-sizing :auto))
(dwsh/update-shapes selected #(assoc % :layout-item-h-sizing :fix :layout-item-v-sizing :fix))))
(dwsh/update-shapes selected ctl/toggle-fix-if-auto)))
(rx/of (ptk/data-event :layout/update {:ids [new-shape-id]})
(dwu/commit-undo-transaction undo-id))))))))