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