mirror of
https://github.com/penpot/penpot.git
synced 2026-09-11 22:49:30 +00:00
Merge pull request #8568 from penpot/niwinz-staging-bugfix-1-path-get-points
🐛 Fix TypeError when path content is nil in get-points calls
This commit is contained in:
commit
1680be33ef
@ -270,6 +270,15 @@
|
|||||||
(t/is (= result1 result2))
|
(t/is (= result1 result2))
|
||||||
(t/is (= result2 result3))))
|
(t/is (= result2 result3))))
|
||||||
|
|
||||||
|
(t/deftest path-get-points-nil-safe
|
||||||
|
(t/testing "path/get-points returns nil for nil content without throwing"
|
||||||
|
(t/is (nil? (path/get-points nil))))
|
||||||
|
(t/testing "path/get-points returns correct points for valid content"
|
||||||
|
(let [content (path/content sample-content)
|
||||||
|
points (path/get-points content)]
|
||||||
|
(t/is (some? points))
|
||||||
|
(t/is (= 3 (count points))))))
|
||||||
|
|
||||||
(defn calculate-extremities
|
(defn calculate-extremities
|
||||||
"Calculate extremities for the provided content.
|
"Calculate extremities for the provided content.
|
||||||
A legacy implementation used mainly as reference for testing"
|
A legacy implementation used mainly as reference for testing"
|
||||||
|
|||||||
@ -59,8 +59,8 @@
|
|||||||
content (get shape :content)
|
content (get shape :content)
|
||||||
new-content (path/apply-content-modifiers content content-modifiers)
|
new-content (path/apply-content-modifiers content content-modifiers)
|
||||||
|
|
||||||
old-points (path.segment/get-points content)
|
old-points (path/get-points content)
|
||||||
new-points (path.segment/get-points new-content)
|
new-points (path/get-points new-content)
|
||||||
point-change (->> (map hash-map old-points new-points) (reduce merge))]
|
point-change (->> (map hash-map old-points new-points) (reduce merge))]
|
||||||
|
|
||||||
(when (and (some? new-content) (some? shape))
|
(when (and (some? new-content) (some? shape))
|
||||||
@ -162,7 +162,7 @@
|
|||||||
start-position (apply min-key #(gpt/distance start-position %) selected-points)
|
start-position (apply min-key #(gpt/distance start-position %) selected-points)
|
||||||
|
|
||||||
content (st/get-path state :content)
|
content (st/get-path state :content)
|
||||||
points (path.segment/get-points content)]
|
points (path/get-points content)]
|
||||||
|
|
||||||
(rx/concat
|
(rx/concat
|
||||||
;; This stream checks the consecutive mouse positions to do the dragging
|
;; This stream checks the consecutive mouse positions to do the dragging
|
||||||
@ -255,7 +255,7 @@
|
|||||||
start-delta-y (dm/get-in modifiers [index cy] 0)
|
start-delta-y (dm/get-in modifiers [index cy] 0)
|
||||||
|
|
||||||
content (st/get-path state :content)
|
content (st/get-path state :content)
|
||||||
points (path.segment/get-points content)
|
points (path/get-points content)
|
||||||
|
|
||||||
point (-> content (nth (if (= prefix :c1) (dec index) index)) (path.helpers/segment->point))
|
point (-> content (nth (if (= prefix :c1) (dec index) index)) (path.helpers/segment->point))
|
||||||
handler (-> content (nth index) (path.segment/get-handler prefix))
|
handler (-> content (nth index) (path.segment/get-handler prefix))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user