Skip to content

Invalid lifecycle for ReactDialog #12093

@CamilleLetavernier

Description

@CamilleLetavernier

Bug Description:

In #11669, a fix was provided to support re-opening a ReactDialog that had been closed. However, trying to reopen/reuse a widget that has been previously disposed violates the widget API, which may cause further issues. Especially, BaseWidget.dispose() can only be invoked once, so the reused/revived widget can no longer be disposed after this.

As a consequence, dialogs based on ReactDialog now have an inconsistent lifecycle, which causes errors:

ERROR Warning: You are calling ReactDOMClient.createRoot() on a container that has already been passed to createRoot() before. Instead, call root.render() on the existing root instead if you want to update it.

My understanding is that we shouldn't be trying to reuse closed (disposed) Dialogs in the first place; instead, a new instance of the dialog should be created after the previous one was closed/disposed.

Steps to Reproduce:

  1. In the Theia Browser Example, open the AboutDialog
  2. Close it using Esc key or X button: Dialog is properly disposed
  3. Reopen it: Dialog is "successfully" reused, but is still flagged as disposed
  4. Close it again: Dispose is not properly invoked, because the widget is already disposed
  5. Reopen it once more: A React error is thrown, because we're trying to mount the dialog again, even though it wasn't successfully unmounted in the previous step
ERROR Warning: You are calling ReactDOMClient.createRoot() on a container that has already been passed to createRoot() before. Instead, call root.render() on the existing root instead if you want to update it.

Additional Information

  • Operating System: Any
  • Theia Version: Tested on 1.33.0, but probably any version >= 1.30.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    dialogsissues related to dialogsreactissues related to the react language

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions