🐛 Fix unexpected console errors on removing shape.

Caused because in some instances selected shapes set
will contain an id that is already removed from object.
This is a tipical race condition.
This commit is contained in:
Andrey Antukh 2021-04-13 13:10:51 +02:00
parent 239ec12529
commit 94ccc013d7
4 changed files with 15 additions and 11 deletions

View file

@ -233,7 +233,8 @@
:stroke-width (/ select-guide-width zoom)
:stroke-dasharray (/ select-guide-dasharray zoom)}}])])
(mf/defc measurement [{:keys [bounds frame selected-shapes hover-shape zoom]}]
(mf/defc measurement
[{:keys [bounds frame selected-shapes hover-shape zoom]}]
(let [selected-ids (into #{} (map :id) selected-shapes)
selected-selrect (gsh/selection-rect selected-shapes)
hover-selrect (:selrect hover-shape)

View file

@ -88,7 +88,11 @@
zoom (d/check-num zoom 1)
drawing-tool (:tool drawing)
drawing-obj (:object drawing)
selected-shapes (->> selected (mapv #(get objects %)))
selected-shapes (into []
(comp (map #(get objects %))
(filter some?))
selected)
selected-frames (into #{} (map :frame-id) selected-shapes)
;; Only when we have all the selected shapes in one frame

View file

@ -97,7 +97,8 @@
shapes (->> outlines-ids
(filter #(not= edition %))
(map #(get objects %))
(filterv show-outline?))]
(filterv show-outline?)
(filter some?))]
[:g.outlines {:display (when (some? transform) "none")}
[:& shape-outlines-render {:shapes shapes

View file

@ -90,9 +90,7 @@
(let [target (.-target ^js event)]
(when (and (not (.-isContentEditable target)) ;; ignore when pasting into
(not= (.-tagName target) "INPUT")) ;; an editable control
(-> ^js event
(.getBrowserEvent)
(.-clipboardData)))))
(.. ^js event getBrowserEvent -clipboardData))))
(defn extract-text
[clipboard-data]