0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-13 02:28:18 -05:00

Improve layers multiselection behaviour

This commit is contained in:
Alejandro Alonso 2023-09-01 07:46:32 +02:00 committed by Andrey Antukh
parent c83d028466
commit 92ff5de538
2 changed files with 11 additions and 4 deletions

View file

@ -4,7 +4,8 @@
### :sparkles: New features ### :sparkles: New features
- Colorpicker: remember last color mode [Taiga #5508](https://tree.taiga.io/project/penpot/issue/5508) - Remember last color mode in colorpicker [Taiga #5508](https://tree.taiga.io/project/penpot/issue/5508)
- Improve layers multiselection behaviour [Github #5741](https://github.com/penpot/penpot/issues/5741)
### :bug: Bugs fixed ### :bug: Bugs fixed

View file

@ -122,7 +122,9 @@
(ptk/reify ::select-shape (ptk/reify ::select-shape
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(update-in state [:workspace-local :selected] d/toggle-selection id toggle?)) (-> state
(update-in [:workspace-local :selected] d/toggle-selection id toggle?)
(assoc-in [:workspace-local :last-selected] id)))
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [_ state _]
@ -185,7 +187,9 @@
(ptk/reify ::deselect-shape (ptk/reify ::deselect-shape
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(update-in state [:workspace-local :selected] disj id)))) (-> state
(update-in [:workspace-local :selected] disj id)
(update :workspace-local dissoc :last-selected)))))
(defn shift-select-shapes (defn shift-select-shapes
([id] ([id]
@ -196,12 +200,14 @@
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(let [objects (or objects (wsh/lookup-page-objects state)) (let [objects (or objects (wsh/lookup-page-objects state))
append-to-selection (cph/expand-region-selection objects (into #{} [(get-in state [:workspace-local :last-selected]) id]))
selection (-> state selection (-> state
wsh/lookup-selected wsh/lookup-selected
(conj id))] (conj id))]
(-> state (-> state
(assoc-in [:workspace-local :selected] (assoc-in [:workspace-local :selected]
(cph/expand-region-selection objects selection)))))))) (set/union selection append-to-selection))
(update :workspace-local assoc :last-selected id)))))))
(defn select-shapes (defn select-shapes
[ids] [ids]