Yoga | dirty YGNode when removing it from parent#1868
Closed
YonahKarp wants to merge 1 commit into
Closed
Conversation
|
@facebook-github-bot is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
faebbfa to
1c687a9
Compare
Summary: X-link: react/react-native#55411 ## Context When a child node is removed from its parent via YGNodeRemoveChild, the child's calculated layout is cleared (setLayout({})) but the child node is not marked dirty. This causes issues when the view is removed views and later reused with the same layout values. the layout values were cleared (resulting in NaN/0), but since the layout values are the same for the newly reattached node, it isn't dirtied. However, the user would expect it to be dirty, as: a) a fully new node would be dirty by default. b) They just set layout **Example**: - Node is removed from the view and it's layout is cleared. - Node is reattatched and set with height/width that happens to be same as previous - Checking if the view is dirty unexpectedly gives false, despite user setting a "new" value. - Pulling height/width gives 0, as layout hasn't been recalculated yet ## This Diff Marks the removed child node as dirty when clearing its layout in YGNodeRemoveChild, ensuring that subsequent layout calculations will properly recalculate the child's layout values Reviewed By: NickGerleman Differential Revision: D92280506
1c687a9 to
2e3da40
Compare
YonahKarp
pushed a commit
to YonahKarp/react-native
that referenced
this pull request
Feb 10, 2026
Summary: X-link: react/yoga#1868 ## Context When a child node is removed from its parent via YGNodeRemoveChild, the child's calculated layout is cleared (setLayout({})) but the child node is not marked dirty. This causes issues when the view is removed views and later reused with the same layout values. the layout values were cleared (resulting in NaN/0), but since the layout values are the same for the newly reattached node, it isn't dirtied. However, the user would expect it to be dirty, as: a) a fully new node would be dirty by default. b) They just set layout **Example**: - Node is removed from the view and it's layout is cleared. - Node is reattatched and set with height/width that happens to be same as previous - Checking if the view is dirty unexpectedly gives false, despite user setting a "new" value. - Pulling height/width gives 0, as layout hasn't been recalculated yet ## This Diff Marks the removed child node as dirty when clearing its layout in YGNodeRemoveChild, ensuring that subsequent layout calculations will properly recalculate the child's layout values Reviewed By: NickGerleman Differential Revision: D92280506
|
This pull request has been merged in bf81636. |
meta-codesync Bot
pushed a commit
to react/react-native
that referenced
this pull request
Feb 11, 2026
Summary: X-link: react/yoga#1868 Pull Request resolved: #55411 ## Context When a child node is removed from its parent via YGNodeRemoveChild, the child's calculated layout is cleared (setLayout({})) but the child node is not marked dirty. This causes issues when the view is removed views and later reused with the same layout values. the layout values were cleared (resulting in NaN/0), but since the layout values are the same for the newly reattached node, it isn't dirtied. However, the user would expect it to be dirty, as: a) a fully new node would be dirty by default. b) They just set layout **Example**: - Node is removed from the view and it's layout is cleared. - Node is reattatched and set with height/width that happens to be same as previous - Checking if the view is dirty unexpectedly gives false, despite user setting a "new" value. - Pulling height/width gives 0, as layout hasn't been recalculated yet ## This Diff Marks the removed child node as dirty when clearing its layout in YGNodeRemoveChild, ensuring that subsequent layout calculations will properly recalculate the child's layout values ## Changelog: [Internal] [Fixed] - Marks removed child node as dirty when clearing its layout in YGNodeRemoveChild, ensuring that subsequent layout calculations will properly recalculate the child's layout values Reviewed By: NickGerleman Differential Revision: D92280506 fbshipit-source-id: 6f1adb6f5b8cbe9d3461746b613e42f890b1e75e
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:
Context
When a child node is removed from its parent via YGNodeRemoveChild, the child's calculated layout is cleared (setLayout({})) but the child node is not marked dirty. This causes issues when the view is removed views and later reused with the same layout values. the layout values were cleared (resulting in NaN/0), but since the layout values are the same for the newly reattached node, it isn't dirtied. However, the user would expect it to be dirty, as:
a) a fully new node would be dirty by default.
b) They just set layout
Example:
This Diff
Marks the removed child node as dirty when clearing its layout in YGNodeRemoveChild, ensuring that subsequent layout calculations will properly recalculate the child's layout values
Reviewed By: NickGerleman
Differential Revision: D92280506