From ee7c3ece758dd1048fd9aff76cf5022b560fef29 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 13 Jul 2023 10:50:39 +0200 Subject: [PATCH] :bug: Fix selection bug on path edition --- .../main/data/workspace/path/selection.cljs | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/frontend/src/app/main/data/workspace/path/selection.cljs b/frontend/src/app/main/data/workspace/path/selection.cljs index b5f514d82..4d517eaf6 100644 --- a/frontend/src/app/main/data/workspace/path/selection.cljs +++ b/frontend/src/app/main/data/workspace/path/selection.cljs @@ -6,6 +6,7 @@ (ns app.main.data.workspace.path.selection (:require + [app.common.data.macros :as dm] [app.common.geom.point :as gpt] [app.common.geom.rect :as grc] [app.common.geom.shapes :as gsh] @@ -43,20 +44,27 @@ (let [id (st/get-path-id state)] (update-in state [:workspace-local :edit-path id :hover-handlers] disj [index prefix]))))) -(defn select-node-area [shift?] +(defn select-node-area + [shift?] (ptk/reify ::select-node-area ptk/UpdateEvent (update [_ state] - (let [selrect (get-in state [:workspace-local :selrect]) - id (get-in state [:workspace-local :edition]) - content (st/get-path state :content) - selected-point? #(gsh/has-point-rect? selrect %) - selected-points (or (get-in state [:workspace-local :edit-path id :selected-points]) #{}) - positions (into (if shift? selected-points #{}) - (comp (filter #(not (= (:command %) :close-path))) + (let [selrect (dm/get-in state [:workspace-local :selrect]) + id (dm/get-in state [:workspace-local :edition]) + content (st/get-path state :content) + + selected-point? (if (some? selrect) + (partial gsh/has-point-rect? selrect) + (constantly false)) + + selected-points (dm/get-in state [:workspace-local :edit-path id :selected-points]) + selected-points (or selected-points #{}) + + xform (comp (filter #(not (= (:command %) :close-path))) (map (comp gpt/point :params)) (filter selected-point?)) - content)] + positions (into (if shift? selected-points #{}) xform content)] + (cond-> state (some? id) (assoc-in [:workspace-local :edit-path id :selected-points] positions))))))