From 9e348ecc9929513e787350cf2312edeff9164644 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Mon, 5 Apr 2021 11:23:46 +0200 Subject: [PATCH] :bug: Fixed problem when editing paths --- frontend/src/app/main/data/workspace/common.cljs | 4 ++-- frontend/src/app/main/ui/workspace/viewport.cljs | 7 ++++--- .../src/app/main/ui/workspace/viewport/actions.cljs | 12 ++++++------ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/frontend/src/app/main/data/workspace/common.cljs b/frontend/src/app/main/data/workspace/common.cljs index c767a5251..21654d4f7 100644 --- a/frontend/src/app/main/data/workspace/common.cljs +++ b/frontend/src/app/main/data/workspace/common.cljs @@ -547,8 +547,8 @@ (update [_ state] (let [id (get-in state [:workspace-local :edition])] (-> state - (update-in [:workspace-local :hover] disj id) - (update :workspace-local dissoc :edition)))))) + (update :workspace-local dissoc :edition) + (cond-> (some? id) (update-in [:workspace-local :edit-path] dissoc id))))))) (defn get-shape-layer-position [objects selected attrs] diff --git a/frontend/src/app/main/ui/workspace/viewport.cljs b/frontend/src/app/main/ui/workspace/viewport.cljs index 6f50b4593..91876fa23 100644 --- a/frontend/src/app/main/ui/workspace/viewport.cljs +++ b/frontend/src/app/main/ui/workspace/viewport.cljs @@ -87,10 +87,11 @@ drawing-tool (:tool drawing) drawing-obj (:object drawing) - drawing-path? (and edition (= :draw (get-in edit-path [edition :edit-mode]))) + 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]))) - on-click (actions/on-click hover selected) + on-click (actions/on-click hover selected edition drawing-path?) on-context-menu (actions/on-context-menu hover) on-double-click (actions/on-double-click hover hover-ids drawing-path? objects) on-drag-enter (actions/on-drag-enter) @@ -115,7 +116,7 @@ show-draw-area? drawing-obj show-gradient-handlers? (= (count selected) 1) show-grids? (contains? layout :display-grid) - show-outlines? (and (nil? transform) (not edit-path)) + show-outlines? (and (nil? transform) (not edition) (not drawing-obj)) show-pixel-grid? (>= zoom 8) show-presence? page-id show-prototypes? (= options-mode :prototype) diff --git a/frontend/src/app/main/ui/workspace/viewport/actions.cljs b/frontend/src/app/main/ui/workspace/viewport/actions.cljs index f68382016..2a4bef182 100644 --- a/frontend/src/app/main/ui/workspace/viewport/actions.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/actions.cljs @@ -32,7 +32,7 @@ (defn on-mouse-down [{:keys [id blocked hidden type]} drawing-tool text-editing? edition edit-path selected] (mf/use-callback - (mf/deps id blocked hidden type drawing-tool text-editing? edition selected) + (mf/deps id blocked hidden type drawing-tool text-editing? edition edit-path selected) (fn [bevent] (when (dom/class? (dom/get-target bevent) "viewport-controls") (dom/stop-propagation bevent) @@ -63,14 +63,14 @@ (and drawing-tool (not (#{:comments :path} drawing-tool))) (st/emit! (dd/start-drawing drawing-tool)) - edit-path + (and edit-path (contains? edit-path edition)) ;; Handle node select-drawing. NOP at the moment nil (or (not id) (and frame? (not selected?))) (st/emit! (dw/handle-selection shift?)) - :else + (not drawing-tool) (st/emit! (when (or shift? (not selected?)) (dw/select-shape id shift?)) (when (not shift?) @@ -119,9 +119,9 @@ (reset! frame-hover nil)))) (defn on-click - [hover selected] + [hover selected edition drawing-path?] (mf/use-callback - (mf/deps @hover selected) + (mf/deps @hover selected edition drawing-path?) (fn [event] (when (dom/class? (dom/get-target event) "viewport-controls") (let [ctrl? (kbd/ctrl? event) @@ -133,7 +133,7 @@ selected? (contains? selected (:id @hover))] (st/emit! (ms/->MouseEvent :click ctrl? shift? alt?)) - (when (and hovering? (not shift?) (not frame?) (not selected?)) + (when (and hovering? (not shift?) (not frame?) (not selected?) (not edition) (not drawing-path?)) (st/emit! (dw/select-shape (:id @hover))))))))) (defn on-double-click