GrapesJS version
What browser are you using?
Chrome
Reproducible demo link
https://codepen.io/Logeshwaran-codepen/pen/raLJpYb
Describe the bug
How to reproduce the bug?
- Select components that available in canvas. Listen to a lifecycle event (e.g. component:selected)
- Call component.replaceWith() inside the event handler
- Perform undo
What is the expected behavior?
Undo should safely restore editor state without errors, or GrapesJS should provide a supported way to replace components during lifecycle events.
What is the current behavior?
Undo crashes because GrapesJS tries to restore selection/state for a component that no longer exists.
Question
Is there a recommended, undo-safe way to replace a component during selection or status change events?
Code of Conduct