Merge pull request #8290 from penpot/alotor-fix-alt-duplicate

🐛 Fix problem with alt+move for duplicate shapes
This commit is contained in:
Alejandro Alonso 2026-02-09 06:33:13 +01:00 committed by GitHub
commit e5cdb5b163
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -621,7 +621,7 @@
(->> stream (->> stream
(rx/filter (ptk/type? ::dws/duplicate-selected)) (rx/filter (ptk/type? ::dws/duplicate-selected))
(rx/take 1) (rx/take 1)
(rx/map #(start-move from-position)))))) (rx/map #(start-move from-position nil true))))))
(defn get-drop-cell (defn get-drop-cell
[target-frame objects position] [target-frame objects position]
@ -641,8 +641,9 @@
(dom/set-property! node "transform" (gmt/translate-matrix move-vector)))))) (dom/set-property! node "transform" (gmt/translate-matrix move-vector))))))
(defn start-move (defn start-move
([from-position] (start-move from-position nil)) ([from-position] (start-move from-position nil false))
([from-position ids] ([from-position ids] (start-move from-position ids false))
([from-position ids from-duplicate?]
(ptk/reify ::start-move (ptk/reify ::start-move
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
@ -750,38 +751,47 @@
(rx/share))] (rx/share))]
(if (features/active-feature? state "render-wasm/v1") (if (features/active-feature? state "render-wasm/v1")
(rx/merge (let [duplicate-stopper
(->> modifiers-stream (->> ms/mouse-position-alt
(rx/map (rx/mapcat
(fn [[modifiers snap-ignore-axis]] (fn [alt?]
(dwm/set-wasm-modifiers modifiers :snap-ignore-axis snap-ignore-axis)))) (if (and alt? (not from-duplicate?))
(rx/of true)
(rx/empty)))))]
(rx/merge
(->> modifiers-stream
(rx/take-until duplicate-stopper)
(rx/map
(fn [[modifiers snap-ignore-axis]]
(dwm/set-wasm-modifiers modifiers :snap-ignore-axis snap-ignore-axis))))
(->> move-stream (->> move-stream
(rx/with-latest-from ms/mouse-position-alt) (rx/with-latest-from ms/mouse-position-alt)
(rx/filter (fn [[_ alt?]] alt?)) (rx/filter (fn [[_ alt?]] alt?))
(rx/take 1) (rx/take 1)
(rx/mapcat (rx/mapcat
(fn [[_ alt?]] (fn [[_ alt?]]
(if (and (not duplicate-move-started?) alt?) (if (and (not from-duplicate?) alt?)
(rx/of (start-move-duplicate from-position) (rx/of (start-move-duplicate from-position)
(dws/duplicate-selected false true)) (dws/duplicate-selected false true))
(rx/empty))))) (rx/empty)))))
;; Last event will write the modifiers creating the changes ;; Last event will write the modifiers creating the changes
(->> move-stream (->> move-stream
(rx/last) (rx/last)
(rx/with-latest-from modifiers-stream) (rx/take-until duplicate-stopper)
(rx/mapcat (rx/with-latest-from modifiers-stream)
(fn [[[_ target-frame drop-index drop-cell] [modifiers snap-ignore-axis]]] (rx/mapcat
(let [undo-id (js/Symbol)] (fn [[[_ target-frame drop-index drop-cell] [modifiers snap-ignore-axis]]]
(rx/of (let [undo-id (js/Symbol)]
(dwu/start-undo-transaction undo-id) (rx/of
(dwm/apply-wasm-modifiers modifiers (dwu/start-undo-transaction undo-id)
:snap-ignore-axis snap-ignore-axis (dwm/apply-wasm-modifiers modifiers
:undo-transation? false) :snap-ignore-axis snap-ignore-axis
(move-shapes-to-frame ids target-frame drop-index drop-cell) :undo-transation? false)
(finish-transform) (move-shapes-to-frame ids target-frame drop-index drop-cell)
(dwu/commit-undo-transaction undo-id))))))) (finish-transform)
(dwu/commit-undo-transaction undo-id))))))))
(rx/merge (rx/merge
(->> modifiers-stream (->> modifiers-stream