Skip to content

Yoga | dirty YGNode when removing it from parent#55411

Open
YonahKarp wants to merge 1 commit intofacebook:mainfrom
YonahKarp:export-D92280506
Open

Yoga | dirty YGNode when removing it from parent#55411
YonahKarp wants to merge 1 commit intofacebook:mainfrom
YonahKarp:export-D92280506

Conversation

@YonahKarp
Copy link

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:

  • 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

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**:
- 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
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants