Skip to content

Overlay immediately closes with rootClose in shadow root #90

@angrycat9000

Description

@angrycat9000

Describe the bug

Overlay with rootClose closes as soon as it is opened if it is hosted inside of a custom element shadow root.

I'm using custom elements to isolate some react based components that are hosted in an older application. The Overlay immediately closes when opened if it is hosted inside of a shadow root of a custom element. The same code works correctly when hosted in the light dom.

To Reproduce

Steps to reproduce the behavior:

  1. Create a custom element with a shadow root that hosts a react render root
  2. Render a Overlay with rootClose and onHide set. Also have the container option point to an element in the shadow root
  3. Click the button to open the overlay.

Reproducible Example

https://codesandbox.io/s/bold-dan-5kfh5r - Declares a custom element in index.js and has it render the same React component as is rendered in the light DOM. The custom element embedded version does not work, the light DOM version does.

  • Click the Show in shadow root button. Note the popover flashes and then disappears.
  • Click Show in light DOM button. Note that the popover appears and remains visibile.

Expected behavior

The popover remains open until an additional click.

Screenshots

Screencast.from.08-08-2023.10.04.38.AM.webm

Environment (please complete the following information)

  • Operating System: Linux
  • Browser, Version: Chrome 115.0.5790.110
    image

Additional context

This seems to be related to a change between React 17 and React 18. Was not able to reproduce it using React 17 or the legacy ReactDOM.render method in React 18.

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