🐛 Rename a component and its main in one undo step

Renaming a component from the assets panel renames the component, then
its main root, in two commits. Undo took them back one at a time, so a
single undo left the component and its main with different names. They
are now one undo transaction.

Found by the frontend replay of generated programs with the new rename
kind. The JVM benchmark does not run frontend events; it is not run.

AI-assisted-by: claude-opus-5-5
This commit is contained in:
alonso.torres 2026-11-14 03:22:17 +01:00
parent e5a9f97112
commit f5c2705344

View File

@ -452,13 +452,18 @@
(when (and (some? clean-name) component)
(let [shape-id (:main-instance-id component)
page-id (:main-instance-page component)]
page-id (:main-instance-page component)
undo-id (js/Symbol)]
;; the component and its main root are renamed in one undo step
(rx/concat
(rx/of (rename-component component-id clean-name))
(rx/of (dwu/start-undo-transaction undo-id)
(rename-component component-id clean-name))
(when (and shape-id page-id)
(rx/of (dwsh/update-shapes [shape-id] #(assoc % :name clean-name) {:page-id page-id :stack-undo? true}))))))))))
(rx/of (dwsh/update-shapes [shape-id] #(assoc % :name clean-name) {:page-id page-id :stack-undo? true})))
(rx/of (dwu/commit-undo-transaction undo-id)))))))))
(defn duplicate-component
"Create a new component copied from the one with the given id."