From d470d968337e789e3dff9fb2329dd2834c5b9d3d Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Wed, 7 Jan 2026 11:00:02 +0100 Subject: [PATCH] :bug: Fix problem with dragging handlers --- common/src/app/common/types/path.cljc | 6 ++- .../app/main/data/workspace/path/edition.cljs | 41 +++++++++---------- .../main/ui/workspace/shapes/path/editor.cljs | 9 ++-- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/common/src/app/common/types/path.cljc b/common/src/app/common/types/path.cljc index b47eca63c0..be0e15b1aa 100644 --- a/common/src/app/common/types/path.cljc +++ b/common/src/app/common/types/path.cljc @@ -112,8 +112,10 @@ (:c2y params) (update-in [index :params :c2y] + (:c2y params))) content))] - (impl/path-data - (reduce apply-to-index (vec content) modifiers)))) + (if (some? modifiers) + (impl/path-data + (reduce apply-to-index (vec content) modifiers)) + content))) (defn transform-content "Applies a transformation matrix over content and returns a new diff --git a/frontend/src/app/main/data/workspace/path/edition.cljs b/frontend/src/app/main/data/workspace/path/edition.cljs index 8839947701..1210111f71 100644 --- a/frontend/src/app/main/data/workspace/path/edition.cljs +++ b/frontend/src/app/main/data/workspace/path/edition.cljs @@ -47,32 +47,31 @@ (ptk/reify ::apply-content-modifiers ptk/WatchEvent (watch [it state _] - (let [page-id (get state :current-page-id state) - objects (dsh/lookup-page-objects state) - - id (st/get-path-id state) - - shape - (st/get-path state) + (let [id (st/get-path-id state) + shape (st/get-path state) content-modifiers - (dm/get-in state [:workspace-local :edit-path id :content-modifiers]) + (dm/get-in state [:workspace-local :edit-path id :content-modifiers])] + (if (or (nil? shape) (nil? content-modifiers)) + (rx/of (dwe/clear-edition-mode)) + (let [page-id (get state :current-page-id state) + objects (dsh/lookup-page-objects state) - content (get shape :content) - new-content (path/apply-content-modifiers content content-modifiers) + content (get shape :content) + new-content (path/apply-content-modifiers content content-modifiers) - old-points (path.segment/get-points content) - new-points (path.segment/get-points new-content) - point-change (->> (map hash-map old-points new-points) (reduce merge))] + old-points (path.segment/get-points content) + new-points (path.segment/get-points new-content) + point-change (->> (map hash-map old-points new-points) (reduce merge))] - (when (and (some? new-content) (some? shape)) - (let [changes (changes/generate-path-changes it objects page-id shape (:content shape) new-content)] - (if (empty? new-content) - (rx/of (dch/commit-changes changes) - (dwe/clear-edition-mode)) - (rx/of (dch/commit-changes changes) - (selection/update-selection point-change) - (fn [state] (update-in state [:workspace-local :edit-path id] dissoc :content-modifiers :moving-nodes :moving-handler)))))))))) + (when (and (some? new-content) (some? shape)) + (let [changes (changes/generate-path-changes it objects page-id shape (:content shape) new-content)] + (if (empty? new-content) + (rx/of (dch/commit-changes changes) + (dwe/clear-edition-mode)) + (rx/of (dch/commit-changes changes) + (selection/update-selection point-change) + (fn [state] (update-in state [:workspace-local :edit-path id] dissoc :content-modifiers :moving-nodes :moving-handler)))))))))))) (defn modify-content-point [content {dx :x dy :y} modifiers point] diff --git a/frontend/src/app/main/ui/workspace/shapes/path/editor.cljs b/frontend/src/app/main/ui/workspace/shapes/path/editor.cljs index e93327313d..24996169ac 100644 --- a/frontend/src/app/main/ui/workspace/shapes/path/editor.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/path/editor.cljs @@ -148,11 +148,12 @@ (mf/use-fn (mf/deps index prefix is-move) (fn [event] - (dom/stop-propagation event) - (dom/prevent-default event) + (when (dom/left-mouse? event) + (dom/stop-propagation event) + (dom/prevent-default event) - (when ^boolean is-move - (st/emit! (drp/start-move-handler index prefix)))))] + (when ^boolean is-move + (st/emit! (drp/start-move-handler index prefix))))))] [:g.handler {:pointer-events (if ^boolean is-draw "none" "visible")} [:line