-
Notifications
You must be signed in to change notification settings - Fork 26
Description
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:
- Create a custom element with a shadow root that hosts a react render root
- Render a Overlay with
rootClose
andonHide
set. Also have thecontainer
option point to an element in the shadow root - 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)
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.