Skip to content

Event not working when the react app is rendered inside the web component issue fix. #17991

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

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/react-dom/src/events/getEventTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ function getEventTarget(nativeEvent) {
// Fallback to nativeEvent.srcElement for IE9
// https://github.com/facebook/react/issues/12506
let target = nativeEvent.target || nativeEvent.srcElement || window;
// This is for solve the webcomponent event not working issue. And it will works on all the browsers which are all support the shadowDom.
// https://github.com/facebook/react/issues/9242
let targetPath =
nativeEvent.path ||
(nativeEvent.composedPath && nativeEvent.composedPath());
if (target.shadowRoot && targetPath && targetPath.length) {
target = targetPath[0];
}

// Normalize SVG <use> element events #4963
if (target.correspondingUseElement) {
Expand Down