-
Hoping I can poll the community here. So we know that there are some aspects of RAC that will not work in a shadow tree. One of them is the If anyone has any experience with other known issues when using RAC in a shadow tree it would be very helpful. We have built our design system component library on RAC, and have a team that are prototyping a project using a shadow dom. It would be really helpful if we went into it knowing more about what we might run up against. Thank you everyone. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 12 replies
-
Both of these are fired during the native onClick so they should be the same? Curious what difference you're seeing there. We do have tests for press events in shadow roots: There are certainly other issues. It's not officially supported everywhere, but there have been some contributions to improve it in various areas. It's sort of in a "try it and see if it works" state. |
Beta Was this translation helpful? Give feedback.
-
I can test again, but what I was finding was when using a Button component, the onPress event produced no effect. I did not dig deep, so I could find out more, such as did the event even begin, was it a bubbling issue, etc. Ill update. Thanks for the response, and all the work you both do. I'm very happy I chose React Aria Components for our design system! |
Beta Was this translation helpful? Give feedback.
-
Okay, been a while, finally had time to work on this. The short version is that, for me, Shadow DOM Issue: Root Cause (?) - Event Target Retargeting Breaking onPressSummaryI've conducted an investigation into the Shadow DOM issues with React Aria Components and think I have identified the root cause. The This follows up on the discussion in #8378 where I mentioned The Root Cause: Event Target RetargetingWhen events cross the Shadow DOM boundary, My SluethingI created event tracing that shows the problem: Shadow DOM (BROKEN):
Regular DOM (WORKING):
Why onPressEnd Works But onPress Doesn't?Looking at React Aria's global listeners, I can see the validation logic: "if ((0, $d4ee10de306f2510$export$4282f70798064fe0)(state.target, (0, $d4ee1..." This function appears to validate that the
Why it's an issue for my component libraryThis is particularly problematic for my component library built on React Aria because:
Example that fails in Shadow DOM: <DialogTrigger>
<Button>Open Dialog</Button> {/* No explicit onPress - handled internally */}
<Modal>...</Modal>
</DialogTrigger> Technical Details
The issue is consistent across all modern browsers and appears to be fundamental to how Shadow DOM handles event retargeting rather than a browser-specific bug. That's all I got for now. Hope this was helpful. |
Beta Was this translation helpful? Give feedback.
-
Hey @snowystinger I have an update in the form of a document I saved for myself for future possible implementation. Currently when I render a Modal inside of the shadow dom, when I click on the overlay the modal does not close. For now I don't need it to, but the use case may come up. I have a work around for now, but thought I would share. Sorry, no test case for this one. Shadow DOM Modal Dismiss WorkaroundProblemWhen using React Aria components inside a Shadow DOM, clicking on the modal overlay does not dismiss the modal, even though:
Root CauseReact Aria's dismiss detection mechanism doesn't work properly within Shadow DOM boundaries. Even with The click reaches the overlay container, but React Aria's dismiss handler (which listens at the document level) doesn't properly handle events that originate from within a Shadow DOM? Workaround Solution1. Add click handler in
|
Beta Was this translation helpful? Give feedback.
Fantastic! Enabling this fixed the issue for me. The combination of both
UNSAFE_PortalProvider
andenableShadowDOM
have really helped me as I needed to find a solution and had to work within the structure of the app.I cannot thank you enough, this has helped immensely !
For the heck of it, below, I will attach the solution I was going to try to use, but so happy to use your solution instead.
Would it still be helpful to share my test cases?
Thanks again @snowystinger