Fix parentNode for nested root host views like <Modal>#57623
Closed
rubennorte wants to merge 1 commit into
Closed
Conversation
Summary: `NativeDOM::getParentNode` returned the document for any shadow node carrying the `RootNodeKind` trait. That trait is set not only on a surface's actual root node but also on nested host views such as `<Modal>` (and portal/overlay-style components), so their `parentNode`/`parentElement` incorrectly resolved to the document instead of their real containing element. Because the EventTarget-based event dispatch builds its capture/bubble ancestor path by walking `getParentNode` up the shadow tree, this truncated the path at the modal boundary: a listener registered on an ancestor rendered above the modal never received events (e.g. focus/blur) originating inside it. Fix by returning the document only for the surface's actual root node, identified via `ShadowNode::sameFamily(*currentRevision, *shadowNode)`. Every other node — including nested root-kind nodes — now reports its real structural parent, while disconnected nodes still report none. Changelog: [General][Fixed] - Fix `parentNode`/`parentElement` returning the document instead of the containing element for `<Modal>` and other nested root host views, which severed capture/bubble event propagation to ancestors rendered above them Differential Revision: D113012362
|
@rubennorte has exported this pull request. If you are a Meta employee, you can view the originating Diff in D113012362. |
|
This pull request has been merged in e410ff5. |
react-native-bot
pushed a commit
that referenced
this pull request
Jul 22, 2026
Summary: Pull Request resolved: #57623 `NativeDOM::getParentNode` returned the document for any shadow node carrying the `RootNodeKind` trait. That trait is set not only on a surface's actual root node but also on nested host views such as `<Modal>` (and portal/overlay-style components), so their `parentNode`/`parentElement` incorrectly resolved to the document instead of their real containing element. Because the EventTarget-based event dispatch builds its capture/bubble ancestor path by walking `getParentNode` up the shadow tree, this truncated the path at the modal boundary: a listener registered on an ancestor rendered above the modal never received events (e.g. focus/blur) originating inside it. Fix by returning the document only for the surface's actual root node, identified via `ShadowNode::sameFamily(*currentRevision, *shadowNode)`. Every other node — including nested root-kind nodes — now reports its real structural parent, while disconnected nodes still report none. Changelog: [General][Fixed] - Fix `parentNode`/`parentElement` returning the document instead of the containing element for `<Modal>` and other nested root host views, which severed capture/bubble event propagation to ancestors rendered above them Reviewed By: javache Differential Revision: D113012362 fbshipit-source-id: 88043a9b9de128e7c3c96d8516b0950cbd6c3c68
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
NativeDOM::getParentNodereturned the document for any shadow node carrying theRootNodeKindtrait. That trait is set not only on a surface's actual root node but also on nested host views such as<Modal>(and portal/overlay-style components), so theirparentNode/parentElementincorrectly resolved to the document instead of their real containing element.Because the EventTarget-based event dispatch builds its capture/bubble ancestor path by walking
getParentNodeup the shadow tree, this truncated the path at the modal boundary: a listener registered on an ancestor rendered above the modal never received events (e.g. focus/blur) originating inside it.Fix by returning the document only for the surface's actual root node, identified via
ShadowNode::sameFamily(*currentRevision, *shadowNode). Every other node — including nested root-kind nodes — now reports its real structural parent, while disconnected nodes still report none.Changelog:
[General][Fixed] - Fix
parentNode/parentElementreturning the document instead of the containing element for<Modal>and other nested root host views, which severed capture/bubble event propagation to ancestors rendered above themDifferential Revision: D113012362