diff --git a/common/src/app/common/data.cljc b/common/src/app/common/data.cljc index 0fcdc88f3..a0646bdf7 100644 --- a/common/src/app/common/data.cljc +++ b/common/src/app/common/data.cljc @@ -223,6 +223,20 @@ ([data] (into {} (without-nils) data))) +(defn without-nils-deep + "Given a map remove the `nil` values and when a child map is found + recursively removes them as well." + [data] + (let [data (without-nils + (c/update-vals + data + (fn [value] + (cond-> value + (map? value) + (without-nils-deep)))))] + (when (not-empty? data) + data))) + (defn without-qualified ([] (remove (comp qualified-keyword? key))) diff --git a/frontend/src/app/main/data/workspace/shape_layout.cljs b/frontend/src/app/main/data/workspace/shape_layout.cljs index 45dd0d30c..d09f257a1 100644 --- a/frontend/src/app/main/data/workspace/shape_layout.cljs +++ b/frontend/src/app/main/data/workspace/shape_layout.cljs @@ -553,7 +553,7 @@ parent-ids (->> ids (map #(cph/get-parent-id objects %))) undo-id (js/Symbol)] (rx/of (dwu/start-undo-transaction undo-id) - (dwc/update-shapes ids #(d/deep-merge (or % {}) changes)) + (dwc/update-shapes ids #(d/without-nils-deep (d/deep-merge (or % {}) changes))) (dwc/update-shapes children-ids (partial fix-child-sizing objects changes)) (dwc/update-shapes parent-ids (fn [parent] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/layout_item.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/layout_item.cljs index 1b2a2fc4e..21e9508c0 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/layout_item.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/layout_item.cljs @@ -45,21 +45,18 @@ m1 (when (and (not (= :multiple (:layout-item-margin values))) (= (dm/get-in values [:layout-item-margin :m1]) (dm/get-in values [:layout-item-margin :m3]))) - (dm/get-in values [:layout-item-margin :m1]) - ) + (dm/get-in values [:layout-item-margin :m1])) m2 (when (and (not (= :multiple (:layout-item-margin values))) (= (dm/get-in values [:layout-item-margin :m2]) (dm/get-in values [:layout-item-margin :m4]))) - (dm/get-in values [:layout-item-margin :m2]) - ) + (dm/get-in values [:layout-item-margin :m2])) select-margins (fn [m1? m2? m3? m4?] (st/emit! (udw/set-margins-selected {:m1 m1? :m2 m2? :m3 m3? :m4 m4?}))) select-margin #(select-margins (= % :m1) (= % :m2) (= % :m3) (= % :m4))] - (mf/use-effect (fn [] (fn []