Add useTraitHiddenOnIOS feature flag#56655
Open
SudoPlz wants to merge 1 commit intofacebook:mainfrom
Open
Conversation
Mirrors useTraitHiddenOnAndroid (facebook#54112) on iOS so apps can opt out of the `Trait::Hidden` slice-skip optimization in sliceChildShadowNodeViewPairs. When the flag is `false`, Hidden subtrees remain in the mount slice and are hidden via `UIView.hidden = YES` through the existing UIView+ComponentViewProtocol path (D8460108, 2018) instead of being torn down via REMOVE + DELETE. Default `true` so iOS behaviour is unchanged for everyone who doesn't override it.
1253d1e to
8dcdb70
Compare
This was referenced Apr 29, 2026
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.
Closes #56656.
Summary:
Adds
useTraitHiddenOnIOS, the iOS twin ofuseTraitHiddenOnAndroid. Defaults totrueso iOS behaviour is unchanged.Set it to
falseandTrait::Hiddensubtrees stay mounted and get hidden viaUIView.hidden = YESinstead of being torn down viaREMOVE + DELETE. That hide path has been in the codebase since 2018 — the 2020 slice-skip just makes it unreachable on iOS by default.Why does this matter?
Custom Fabric components that mutate native state via Commands (the same way
RCTTextInput.focus()andRCTScrollView.scrollTo()do) lose that state silently every time an ancestor togglesdisplay: none. Commands have no prop-shape, so React can't replay them onto the freshly-built instance. And<Suspense>flipsdisplay: noneevery time it suspends — so anything below a Suspense boundary that holds Command-set state is exposed today.10-second, 3-tap reproducer: https://github.com/SudoPlz/reproducer-react-native.
Why a flag instead of just flipping the default?
Same approach as #54112 — the existing platform behaviour stays the default, apps opt out if they need to. No surprises for anyone not actively reaching for it.
Changelog:
[IOS] [ADDED] -
useTraitHiddenOnIOSfeature flag (defaults totrue)Test Plan:
zIndexAndFlattenedNodesinStackingContextTest.cppalready exercisesdisplay: noneand asserts the iOS arm via#ifdef ANDROID / #else. With the flag at its defaulttruethat assertion still holds, so existing-behaviour coverage is free.displayNoneRespectsUseTraitHiddenOnIOSOptOutoverrides the flag tofalseand asserts the inverse: Hidden subtree stays mounted, mirroring what the Android arm already says. Skipped on Android viaGTEST_SKIPbecause the iOS gate is unreachable there.