diff --git a/CHANGES.md b/CHANGES.md index 2a35c4f0e..48de72a2f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -82,6 +82,7 @@ ### :bug: Bugs fixed - Fix issue with shift+select to deselect shapes [Taiga #3154](https://tree.taiga.io/project/penpot/issue/3154) +- Fix issue with drag-select shapes [Taiga #3165](https://tree.taiga.io/project/penpot/issue/3165) ## 1.12.2-beta diff --git a/frontend/src/app/main/data/workspace/selection.cljs b/frontend/src/app/main/data/workspace/selection.cljs index fbe5a8d38..a48329c06 100644 --- a/frontend/src/app/main/data/workspace/selection.cljs +++ b/frontend/src/app/main/data/workspace/selection.cljs @@ -110,7 +110,10 @@ (rx/dedupe) (rx/map #(select-shapes-by-current-selrect preserve? ignore-groups?)))) - (rx/of (update-selrect nil))))))) + (->> (rx/of (update-selrect nil)) + ;; We need the async so the current event finishes before updating the selrect + ;; otherwise the `on-click` event will trigger with a `nil` selrect + (rx/observe-on :async))))))) ;; --- Toggle shape's selection status (selected or deselected) diff --git a/frontend/src/app/main/ui/workspace/viewport.cljs b/frontend/src/app/main/ui/workspace/viewport.cljs index 4f058a79f..2eba7eeca 100644 --- a/frontend/src/app/main/ui/workspace/viewport.cljs +++ b/frontend/src/app/main/ui/workspace/viewport.cljs @@ -121,7 +121,7 @@ node-editing? (and edition (not= :text (get-in base-objects [edition :type]))) text-editing? (and edition (= :text (get-in base-objects [edition :type]))) - on-click (actions/on-click hover selected edition drawing-path? drawing-tool space?) + on-click (actions/on-click hover selected edition drawing-path? drawing-tool space? selrect) on-context-menu (actions/on-context-menu hover hover-ids) on-double-click (actions/on-double-click hover hover-ids drawing-path? base-objects edition) on-drag-enter (actions/on-drag-enter) diff --git a/frontend/src/app/main/ui/workspace/viewport/actions.cljs b/frontend/src/app/main/ui/workspace/viewport/actions.cljs index 7d168d2a9..0ad3de7a0 100644 --- a/frontend/src/app/main/ui/workspace/viewport/actions.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/actions.cljs @@ -145,12 +145,13 @@ (reset! frame-hover nil)))) (defn on-click - [hover selected edition drawing-path? drawing-tool space?] + [hover selected edition drawing-path? drawing-tool space? selrect] (mf/use-callback - (mf/deps @hover selected edition drawing-path? drawing-tool @space?) + (mf/deps @hover selected edition drawing-path? drawing-tool @space? selrect) (fn [event] - (when (or (dom/class? (dom/get-target event) "viewport-controls") - (dom/class? (dom/get-target event) "viewport-selrect")) + (when (and (nil? selrect) + (or (dom/class? (dom/get-target event) "viewport-controls") + (dom/class? (dom/get-target event) "viewport-selrect"))) (let [ctrl? (kbd/ctrl? event) shift? (kbd/shift? event) alt? (kbd/alt? event)