mirror of
https://github.com/penpot/penpot.git
synced 2026-05-09 01:58:46 +00:00
🐛 Fix internal error when applying not valid value to margin input (#9311)
This commit is contained in:
parent
9fccee8689
commit
c5f2ffab69
@ -379,7 +379,7 @@
|
||||
:else
|
||||
(assoc object key value)))
|
||||
object))
|
||||
changes)))
|
||||
(without-nils changes))))
|
||||
|
||||
(defn remove-at-index
|
||||
"Takes a vector and returns a vector with an element in the
|
||||
|
||||
@ -532,7 +532,12 @@
|
||||
(t/is (= {nil 0 :b 2} (d/patch-object {nil 0 :a 1 :b 2} {:a nil})))
|
||||
;; transducer arity (1-arg returns a fn)
|
||||
(let [f (d/patch-object {:a 99})]
|
||||
(t/is (= {:a 99 :b 2} (f {:a 1 :b 2})))))
|
||||
(t/is (= {:a 99 :b 2} (f {:a 1 :b 2}))))
|
||||
;; when object is nil, nil values in changes are stripped (not preserved)
|
||||
(t/is (= {} (d/patch-object nil {:a nil})))
|
||||
(t/is (= {:a 1} (d/patch-object nil {:a 1 :b nil})))
|
||||
;; nested path: patching a key that doesn't exist creates a new map without nils
|
||||
(t/is (= {:b {:y 2}} (d/patch-object {:b nil} {:b {:x nil :y 2}}))))
|
||||
|
||||
(t/deftest without-obj-test
|
||||
(t/is (= [1 3] (d/without-obj [1 2 3] 2)))
|
||||
|
||||
@ -555,10 +555,9 @@
|
||||
;; change parent to fixed
|
||||
(and row? auto-height? (every? ctl/fill-height? all-children))
|
||||
(assoc :layout-item-v-sizing :fix))))
|
||||
|
||||
(defn update-layout-child
|
||||
([ids changes] (update-layout-child ids changes nil))
|
||||
([ids changes options]
|
||||
([ids attrs] (update-layout-child ids attrs nil))
|
||||
([ids attrs options]
|
||||
(ptk/reify ::update-layout-child
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
@ -568,20 +567,20 @@
|
||||
children-ids (->> ids (mapcat #(cfh/get-children-ids objects %)))
|
||||
parent-ids (->> ids (map #(cfh/get-parent-id objects %)))
|
||||
undo-id (js/Symbol)
|
||||
margin-attrs (-> (get changes :layout-item-margin)
|
||||
margin-attrs (-> (get attrs :layout-item-margin)
|
||||
keys
|
||||
set)]
|
||||
(rx/of (dwu/start-undo-transaction undo-id)
|
||||
(dwsh/update-shapes ids (d/patch-object changes)
|
||||
(dwsh/update-shapes ids (d/patch-object attrs)
|
||||
(cond-> options
|
||||
(seq margin-attrs)
|
||||
(assoc :changed-sub-attr margin-attrs)))
|
||||
(dwsh/update-shapes children-ids (partial fix-child-sizing objects changes) options)
|
||||
(dwsh/update-shapes children-ids (partial fix-child-sizing objects attrs) options)
|
||||
(dwsh/update-shapes
|
||||
parent-ids
|
||||
(fn [parent objects]
|
||||
(-> parent
|
||||
(fix-parent-sizing objects (set ids) changes)
|
||||
(fix-parent-sizing objects (set ids) attrs)
|
||||
(cond-> (ctl/grid-layout? parent)
|
||||
(ctl/assign-cells objects))))
|
||||
(merge options {:with-objects? true}))
|
||||
|
||||
@ -147,6 +147,7 @@
|
||||
:icon i/margin-top-bottom
|
||||
:min 0
|
||||
:attr :m1
|
||||
:default nil
|
||||
:input-type :vertical-margin
|
||||
:property "Vertical margin "
|
||||
:nillable true
|
||||
@ -178,6 +179,7 @@
|
||||
:min 0
|
||||
:attr :m2
|
||||
:align :right
|
||||
:default nil
|
||||
:input-type :horizontal-margin
|
||||
:property "Horizontal margin"
|
||||
:nillable true
|
||||
@ -270,6 +272,7 @@
|
||||
:icon i/margin-top
|
||||
:class (stl/css :top-margin-wrapper)
|
||||
:min 0
|
||||
:default nil
|
||||
:attr :m1
|
||||
:input-type :vertical-margin
|
||||
:property "Top margin"
|
||||
@ -298,6 +301,7 @@
|
||||
:icon i/margin-right
|
||||
:class (stl/css :right-margin-wrapper)
|
||||
:min 0
|
||||
:default nil
|
||||
:attr :m2
|
||||
:align :right
|
||||
:input-type :horizontal-margin
|
||||
@ -329,6 +333,7 @@
|
||||
:class (stl/css :bottom-margin-wrapper)
|
||||
:min 0
|
||||
:attr :m3
|
||||
:default nil
|
||||
:align :right
|
||||
:input-type :vertical-margin
|
||||
:property "Bottom margin"
|
||||
@ -358,6 +363,7 @@
|
||||
:icon i/margin-left
|
||||
:class (stl/css :left-margin-wrapper)
|
||||
:min 0
|
||||
:default nil
|
||||
:attr :m4
|
||||
:property "Left margin"
|
||||
:input-type :horizontal-margin
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user