From 2c21a049e1805cdb5e218c6572d75096c1edc160 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 7 Jun 2024 13:51:12 +0200 Subject: [PATCH] :bug: Fix problem with moving+selection not working properly --- CHANGES.md | 1 + .../app/main/data/workspace/transforms.cljs | 2 +- frontend/src/app/util/mouse.cljs | 26 ++++++++++++------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d4e659d92..7a755a9e3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -23,6 +23,7 @@ - Fix expand libraries when search results are present [Taiga #7876](https://tree.taiga.io/project/penpot/issue/7876) - Fix color palette default library [Taiga #8029](https://tree.taiga.io/project/penpot/issue/8029) - Component Library is lost after exporting/importing in .zip format [Github #4672](https://github.com/penpot/penpot/issues/4672) +- Fix problem with moving+selection not working properly [Taiga #7943](https://tree.taiga.io/project/penpot/issue/7943) ## 2.0.3 diff --git a/frontend/src/app/main/data/workspace/transforms.cljs b/frontend/src/app/main/data/workspace/transforms.cljs index 7fe33314d..abb7a7c83 100644 --- a/frontend/src/app/main/data/workspace/transforms.cljs +++ b/frontend/src/app/main/data/workspace/transforms.cljs @@ -431,7 +431,7 @@ (watch [_ state stream] (let [initial (deref ms/mouse-position) - stopper (mse/drag-stopper stream) + stopper (mse/drag-stopper stream {:interrupt? false}) zoom (get-in state [:workspace-local :zoom] 1) ;; We toggle the selection so we don't have to wait for the event diff --git a/frontend/src/app/util/mouse.cljs b/frontend/src/app/util/mouse.cljs index 4576ed325..8f3e7652a 100644 --- a/frontend/src/app/util/mouse.cljs +++ b/frontend/src/app/util/mouse.cljs @@ -72,12 +72,20 @@ (defn drag-stopper "Creates a stream to stop drag events. Takes into account the mouse and also if the window loses focus or the esc key is pressed." - [stream] - (rx/merge - (->> stream - (rx/filter blur-event?)) - (->> stream - (rx/filter mouse-event?) - (rx/filter mouse-up-event?)) - (->> stream - (rx/filter #(= % :interrupt))))) + ([stream] + (drag-stopper stream nil)) + ([stream {:keys [blur? up-mouse? interrupt?] :or {blur? true up-mouse? true interrupt? true}}] + (rx/merge + (if blur? + (->> stream + (rx/filter blur-event?)) + (rx/empty)) + (if up-mouse? + (->> stream + (rx/filter mouse-event?) + (rx/filter mouse-up-event?)) + (rx/empty)) + (if interrupt? + (->> stream + (rx/filter #(= % :interrupt))) + (rx/empty)))))