0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-22 14:39:45 -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
[:map {:title "RestoreComponentChange"}
[:type [:= :restore-component]]
[:id ::sm/uuid]]]
[:id ::sm/uuid]
[:page-id ::sm/uuid]]]
[:purge-component
[:map {:title "PurgeComponentChange"}

View file

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

View file

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

View file

@ -483,9 +483,10 @@
(rx/of
(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
(let [changes (-> (pcb/empty-changes it)
(let [page-id (:current-page-id state)
changes (-> (pcb/empty-changes it)
(pcb/with-library-data data)
(pcb/delete-component id))]
(pcb/delete-component id page-id))]
(rx/of (dch/commit-changes changes))))))))

View file

@ -240,7 +240,7 @@
changes (reduce (fn [changes component-id]
;; 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.
(pcb/delete-component changes component-id))
(pcb/delete-component changes component-id (:id page)))
changes
components-to-delete)