diff --git a/common/src/app/common/types/shape/layout.cljc b/common/src/app/common/types/shape/layout.cljc index 423e2a4d2..721eeb93c 100644 --- a/common/src/app/common/types/shape/layout.cljc +++ b/common/src/app/common/types/shape/layout.cljc @@ -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))) diff --git a/frontend/src/app/main/data/workspace/shape_layout.cljs b/frontend/src/app/main/data/workspace/shape_layout.cljs index 7e5d4b3af..cafbba89f 100644 --- a/frontend/src/app/main/data/workspace/shape_layout.cljs +++ b/frontend/src/app/main/data/workspace/shape_layout.cljs @@ -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))))))))