0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 00:40:30 -05:00

🐛 Fix problem with selection after create paths

This commit is contained in:
alonso.torres 2021-04-29 10:54:27 +02:00 committed by Andrés Moya
parent 91f60000b3
commit 907f39c73f
2 changed files with 9 additions and 9 deletions

View file

@ -95,10 +95,12 @@
;; Only when we have all the selected shapes in one frame
selected-frame (when (= (count selected-frames) 1) (get objects (first selected-frames)))
create-comment? (= :comments drawing-tool)
drawing-path? (or (and edition (= :draw (get-in edit-path [edition :edit-mode])))
(and (some? drawing-obj) (= :path (:type drawing-obj))))
text-editing? (and edition (= :text (get-in objects [edition :type])))
path-editing? (and edition (= :path (get-in objects [edition :type])))
text-editing? (and edition (= :text (get-in objects [edition :type])))
on-click (actions/on-click hover selected edition drawing-path? drawing-tool)
on-context-menu (actions/on-context-menu hover)
@ -106,7 +108,7 @@
on-drag-enter (actions/on-drag-enter)
on-drag-over (actions/on-drag-over)
on-drop (actions/on-drop file viewport-ref zoom)
on-mouse-down (actions/on-mouse-down @hover drawing-tool text-editing? edition edit-path selected)
on-mouse-down (actions/on-mouse-down @hover selected edition drawing-tool text-editing? path-editing? drawing-path? create-comment?)
on-mouse-up (actions/on-mouse-up disable-paste)
on-pointer-down (actions/on-pointer-down)
on-pointer-enter (actions/on-pointer-enter in-viewport?)

View file

@ -27,9 +27,9 @@
(:import goog.events.WheelEvent))
(defn on-mouse-down
[{:keys [id blocked hidden type]} drawing-tool text-editing? edition edit-path selected]
[{:keys [id blocked hidden type]} selected edition drawing-tool text-editing? path-editing? drawing-path? create-comment?]
(mf/use-callback
(mf/deps id blocked hidden type drawing-tool text-editing? edition edit-path selected)
(mf/deps id blocked hidden type selected edition drawing-tool text-editing? path-editing? drawing-path? create-comment?)
(fn [bevent]
(when (or (dom/class? (dom/get-target bevent) "viewport-controls")
(dom/class? (dom/get-target bevent) "viewport-selrect"))
@ -44,9 +44,7 @@
middle-click? (= 2 (.-which event))
frame? (= :frame type)
selected? (contains? selected id)
drawing-path? (= :draw (get-in edit-path [edition :edit-mode]))]
selected? (contains? selected id)]
(when middle-click?
(dom/prevent-default bevent)
@ -61,13 +59,13 @@
(when (and (not text-editing?)
(not blocked)
(not hidden)
(not (#{:comments :path} drawing-tool))
(not create-comment?)
(not drawing-path?))
(cond
drawing-tool
(st/emit! (dd/start-drawing drawing-tool))
(and edit-path (contains? edit-path edition))
path-editing?
;; Handle path node area selection
(st/emit! (dwdp/handle-selection shift?))