-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overlay immediately closes with rootClose in shadow root #90
Comments
The original workaround that @jquense added to fix this doesn't work in the shadow DOM because As a result, the click handler is processing twice |
Funny I just saw that material UI has a different work around for the same issue in their ClickAway component, maybe we can try that? |
Unfortunately couldn't get tests to pass with the MUI approach. I'll need to drop this for now, since I'm short on time ATM. |
fair enough, i don't think this is a super pressing use case anyway! |
Hi, any update? Do you need some help to make test passing? I'd like to make it work as soon as possible as the whole react-bootstrap is not working in the shadowDOM. This issue is also visible for Dropdowns. In the shadow tree, dropdown is opened and immediately closed. |
FYI @mklekowski I ended up working around this by not using |
Actually, I have an issue with DropdownButton, when clicking two events are triggered, first for opening and second for closing. Probably it's also possible to disable rootClose and implement it manually, but I prefer to fix it in the library directly. @jquense can you look at the issue? |
Also, the code is using Window/event which is deprecated. Maybe it can be implemented in different way? |
@mklekowski do you have a workaround? I have the same issue as you, with |
Yes and no :) The workaround for me was to change usage of the library to mui/base-ui - it has better support for shadow dom and it looks like it's better maintained. |
Ouch - thank you anyway - I'm bound to Bootstrap though, so hopefully this gets fixed soon. My current workaround is <Dropdown
autoClose="outside"
show={showDropdown}
onToggle={(show, meta) => {
const target = meta.originalEvent?.target as HTMLElement;
if (target.tagName !== "DROP-DOWN") { // "drop-down" is my custom element name
setShowDropdown(show);
}
}}
>
</Dropdown> This makes the Dropdown kinda work, but it doesn't close the menu when you click inside the custom element but outside the button. |
Describe the bug
Overlay
withrootClose
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:
rootClose
andonHide
set. Also have thecontainer
option point to an element in the shadow rootReproducible 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.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.The text was updated successfully, but these errors were encountered: