mirror of
https://github.com/penpot/penpot.git
synced 2025-02-02 04:19:08 -05:00
🐛 Fix issue with shift+select to deselect shapes
This commit is contained in:
parent
d4b52ad4f1
commit
bee40ae35c
5 changed files with 57 additions and 35 deletions
|
@ -72,6 +72,12 @@
|
||||||
### :arrow_up: Deps updates
|
### :arrow_up: Deps updates
|
||||||
### :heart: Community contributions by (Thank you!)
|
### :heart: Community contributions by (Thank you!)
|
||||||
|
|
||||||
|
## 1.12.3-beta
|
||||||
|
|
||||||
|
### :bug: Bugs fixed
|
||||||
|
|
||||||
|
- Fix issue with shift+select to deselect shapes [Taiga #3154](https://tree.taiga.io/project/penpot/issue/3154)
|
||||||
|
|
||||||
## 1.12.2-beta
|
## 1.12.2-beta
|
||||||
|
|
||||||
### :bug: Bugs fixed
|
### :bug: Bugs fixed
|
||||||
|
|
|
@ -653,3 +653,13 @@
|
||||||
(recur acc (step k))
|
(recur acc (step k))
|
||||||
acc)))
|
acc)))
|
||||||
acc))))))
|
acc))))))
|
||||||
|
(defn toggle-selection
|
||||||
|
([set value]
|
||||||
|
(toggle-selection set value false))
|
||||||
|
|
||||||
|
([set value toggle?]
|
||||||
|
(if-not toggle?
|
||||||
|
(conj (ordered-set) value)
|
||||||
|
(if (contains? set value)
|
||||||
|
(disj set value)
|
||||||
|
(conj set value)))))
|
||||||
|
|
|
@ -123,13 +123,7 @@
|
||||||
(ptk/reify ::select-shape
|
(ptk/reify ::select-shape
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:workspace-local :selected]
|
(update-in state [:workspace-local :selected] d/toggle-selection id toggle?))
|
||||||
(fn [selected]
|
|
||||||
(if-not toggle?
|
|
||||||
(conj (d/ordered-set) id)
|
|
||||||
(if (contains? selected id)
|
|
||||||
(disj selected id)
|
|
||||||
(conj selected id))))))
|
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
|
|
|
@ -592,31 +592,46 @@
|
||||||
|
|
||||||
(defn start-move-selected
|
(defn start-move-selected
|
||||||
"Enter mouse move mode, until mouse button is released."
|
"Enter mouse move mode, until mouse button is released."
|
||||||
[]
|
([]
|
||||||
(ptk/reify ::start-move-selected
|
(start-move-selected nil false))
|
||||||
ptk/WatchEvent
|
|
||||||
(watch [_ state stream]
|
|
||||||
(let [initial (deref ms/mouse-position)
|
|
||||||
selected (wsh/lookup-selected state {:omit-blocked? true})
|
|
||||||
stopper (rx/filter ms/mouse-up? stream)
|
|
||||||
zoom (get-in state [:workspace-local :zoom] 1)]
|
|
||||||
(when-not (empty? selected)
|
|
||||||
(->> ms/mouse-position
|
|
||||||
(rx/map #(gpt/to-vec initial %))
|
|
||||||
(rx/map #(gpt/length %))
|
|
||||||
(rx/filter #(> % (/ 10 zoom)))
|
|
||||||
(rx/take 1)
|
|
||||||
(rx/with-latest vector ms/mouse-position-alt)
|
|
||||||
(rx/mapcat
|
|
||||||
(fn [[_ alt?]]
|
|
||||||
(if alt?
|
|
||||||
;; When alt is down we start a duplicate+move
|
|
||||||
(rx/of (start-move-duplicate initial)
|
|
||||||
(dws/duplicate-selected false))
|
|
||||||
;; Otherwise just plain old move
|
|
||||||
(rx/of (start-move initial selected)))))
|
|
||||||
(rx/take-until stopper)))))))
|
|
||||||
|
|
||||||
|
([id shift?]
|
||||||
|
(ptk/reify ::start-move-selected
|
||||||
|
ptk/WatchEvent
|
||||||
|
(watch [_ state stream]
|
||||||
|
(let [initial (deref ms/mouse-position)
|
||||||
|
|
||||||
|
stopper (rx/filter ms/mouse-up? stream)
|
||||||
|
zoom (get-in state [:workspace-local :zoom] 1)
|
||||||
|
|
||||||
|
;; We toggle the selection so we don't have to wait for the event
|
||||||
|
selected
|
||||||
|
(cond-> (wsh/lookup-selected state {:omit-blocked? true})
|
||||||
|
(some? id)
|
||||||
|
(d/toggle-selection id shift?))]
|
||||||
|
|
||||||
|
(when (or (d/not-empty? selected) (some? id))
|
||||||
|
(->> ms/mouse-position
|
||||||
|
(rx/map #(gpt/to-vec initial %))
|
||||||
|
(rx/map #(gpt/length %))
|
||||||
|
(rx/filter #(> % (/ 10 zoom)))
|
||||||
|
(rx/take 1)
|
||||||
|
(rx/with-latest vector ms/mouse-position-alt)
|
||||||
|
(rx/mapcat
|
||||||
|
(fn [[_ alt?]]
|
||||||
|
(rx/concat
|
||||||
|
(if (some? id)
|
||||||
|
(rx/of (dws/select-shape id shift?))
|
||||||
|
(rx/empty))
|
||||||
|
|
||||||
|
(if alt?
|
||||||
|
;; When alt is down we start a duplicate+move
|
||||||
|
(rx/of (start-move-duplicate initial)
|
||||||
|
(dws/duplicate-selected false))
|
||||||
|
|
||||||
|
;; Otherwise just plain old move
|
||||||
|
(rx/of (start-move initial selected))))))
|
||||||
|
(rx/take-until stopper))))))))
|
||||||
(defn- start-move-duplicate
|
(defn- start-move-duplicate
|
||||||
[from-position]
|
[from-position]
|
||||||
(ptk/reify ::start-move-duplicate
|
(ptk/reify ::start-move-duplicate
|
||||||
|
|
|
@ -97,9 +97,7 @@
|
||||||
(st/emit! (dw/handle-area-selection shift? mod?))
|
(st/emit! (dw/handle-area-selection shift? mod?))
|
||||||
|
|
||||||
(not drawing-tool)
|
(not drawing-tool)
|
||||||
(st/emit! (when (or shift? (not selected?))
|
(st/emit! (dw/start-move-selected id shift?)))))))))))
|
||||||
(dw/select-shape id shift?))
|
|
||||||
(dw/start-move-selected)))))))))))
|
|
||||||
|
|
||||||
(defn on-move-selected
|
(defn on-move-selected
|
||||||
[hover hover-ids selected space?]
|
[hover hover-ids selected space?]
|
||||||
|
@ -167,7 +165,6 @@
|
||||||
(when (and hovering?
|
(when (and hovering?
|
||||||
(or (not frame?) mod?)
|
(or (not frame?) mod?)
|
||||||
(not @space?)
|
(not @space?)
|
||||||
(not selected?)
|
|
||||||
(not edition)
|
(not edition)
|
||||||
(not drawing-path?)
|
(not drawing-path?)
|
||||||
(not drawing-tool))
|
(not drawing-tool))
|
||||||
|
|
Loading…
Add table
Reference in a new issue