Skip to content

BUG: Crash when calling component.replaceWith() during lifecycle events with UndoManager enabled #6696

@jasonvijayy

Description

@jasonvijayy

GrapesJS version

  • I confirm to use the latest version of GrapesJS

What browser are you using?

Chrome

Reproducible demo link

https://codepen.io/Logeshwaran-codepen/pen/raLJpYb

Describe the bug

How to reproduce the bug?

  1. Select components that available in canvas. Listen to a lifecycle event (e.g. component:selected)
  2. Call component.replaceWith() inside the event handler
  3. 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

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions