0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-08 16:18:11 -05:00

🐛 Fix bad page-id on undo delete component

This commit is contained in:
Pablo Alba 2024-01-26 14:09:47 +01:00 committed by Andrey Antukh
parent 3620e6b4d7
commit be31371892
5 changed files with 10 additions and 7 deletions

View file

@ -210,7 +210,8 @@
[:restore-component [:restore-component
[:map {:title "RestoreComponentChange"} [:map {:title "RestoreComponentChange"}
[:type [:= :restore-component]] [:type [:= :restore-component]]
[:id ::sm/uuid]]] [:id ::sm/uuid]
[:page-id ::sm/uuid]]]
[:purge-component [:purge-component
[:map {:title "PurgeComponentChange"} [:map {:title "PurgeComponentChange"}

View file

@ -742,13 +742,14 @@
changes))) changes)))
(defn delete-component (defn delete-component
[changes id] [changes id page-id]
(assert-library! changes) (assert-library! changes)
(-> changes (-> changes
(update :redo-changes conj {:type :del-component (update :redo-changes conj {:type :del-component
:id id}) :id id})
(update :undo-changes conj {:type :restore-component (update :undo-changes conj {:type :restore-component
:id id}))) :id id
:page-id page-id})))
(defn restore-component (defn restore-component
([changes id] ([changes id]

View file

@ -551,7 +551,7 @@
(map :component-id)) (map :component-id))
changes (reduce (fn [changes component-id] changes (reduce (fn [changes component-id]
(pcb/delete-component changes component-id)) (pcb/delete-component changes component-id (:id page)))
changes changes
components-to-delete)] components-to-delete)]
changes)) changes))

View file

@ -483,9 +483,10 @@
(rx/of (rx/of
(dwt/clear-thumbnail (:current-file-id state) page-id root-id "component") (dwt/clear-thumbnail (:current-file-id state) page-id root-id "component")
(dwsh/delete-shapes page-id #{root-id}))) ;; Deleting main root triggers component delete (dwsh/delete-shapes page-id #{root-id}))) ;; Deleting main root triggers component delete
(let [changes (-> (pcb/empty-changes it) (let [page-id (:current-page-id state)
changes (-> (pcb/empty-changes it)
(pcb/with-library-data data) (pcb/with-library-data data)
(pcb/delete-component id))] (pcb/delete-component id page-id))]
(rx/of (dch/commit-changes changes)))))))) (rx/of (dch/commit-changes changes))))))))

View file

@ -240,7 +240,7 @@
changes (reduce (fn [changes component-id] changes (reduce (fn [changes component-id]
;; It's important to delete the component before the main instance, because we ;; It's important to delete the component before the main instance, because we
;; need to store the instance position if we want to restore it later. ;; need to store the instance position if we want to restore it later.
(pcb/delete-component changes component-id)) (pcb/delete-component changes component-id (:id page)))
changes changes
components-to-delete) components-to-delete)