🐛 Fix problem when converting an empty frame to layout

This commit is contained in:
alonso.torres 2023-02-23 13:03:03 +01:00 committed by Alejandro Alonso
parent 94f2681223
commit 664f73b8a5

View file

@ -149,17 +149,19 @@
children-ids (into [] (mapcat #(get-in objects [% :shapes])) ids) children-ids (into [] (mapcat #(get-in objects [% :shapes])) ids)
children-shapes (map (d/getf objects) children-ids) children-shapes (map (d/getf objects) children-ids)
parent (get objects (first ids)) parent (get objects (first ids))
flex-params (shapes->flex-params objects children-shapes parent) flex-params (when (d/not-empty? children-shapes)
(shapes->flex-params objects children-shapes parent))
undo-id (js/Symbol)] undo-id (js/Symbol)]
(rx/of (dwu/start-undo-transaction undo-id) (rx/of (dwu/start-undo-transaction undo-id)
(dwc/update-shapes ids (get-layout-initializer type from-frame?)) (dwc/update-shapes ids (get-layout-initializer type from-frame?))
(dwc/update-shapes (dwc/update-shapes
ids ids
(fn [shape] (fn [shape]
(-> shape (cond-> shape
(assoc :layout-item-h-sizing :auto (not from-frame?)
:layout-item-v-sizing :auto) (-> (assoc :layout-item-h-sizing :auto
(merge flex-params)))) :layout-item-v-sizing :auto)
(merge flex-params)))))
(ptk/data-event :layout/update ids) (ptk/data-event :layout/update ids)
(dwc/update-shapes children-ids #(dissoc % :constraints-h :constraints-v)) (dwc/update-shapes children-ids #(dissoc % :constraints-h :constraints-v))
(dwu/commit-undo-transaction undo-id)))))) (dwu/commit-undo-transaction undo-id))))))