fix(Android, Stack v5): set needsCustomLayoutForChildren to true for StackHost#4200
Open
kligarski wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR mitigates a nondeterministic Android orientation-change sizing issue in Stack v5 by preventing Yoga from directly laying out StackHost children, ensuring child positioning is driven by native layout.
Changes:
- Override
needsCustomLayoutForChildren()inStackHostViewManagerto returntrue. - Add rationale in KDoc explaining why Yoga layout for children should be bypassed for
StackHost.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
t0maboro
approved these changes
Jun 23, 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.
Description
Disables layout from Yoga for children of
StackHost. Fixes a nondeterministic bug with incorrect screen size on orientation change.Closes https://github.com/software-mansion/react-native-screens-labs/issues/1499.
Details
On orientation change, sometimes measure & layout from Yoga was applied with incorrect measurements. This is very likely connected to https://github.com/software-mansion/react-native-screens-labs/discussions/543, #3295 but I didn't investigate further why we receive the outdated measurements.
In order to mitigate this, I decided to use similar strategy to
StackHeaderConfig. By enablingneedsCustomLayoutForChildreninStackHostViewManager, we will still receivemeasurewith incorrect width & height from Yoga butlayoutwon't be called. This way, incorrect measurements won't be applied and next native layout will remeasure & apply correct layout. Ultimately, we want the screen to be laid out fully by native layout, not by Yoga, so this is the desired behavior. If anything changes,StackHostreceives new measurement from Yoga and will trigger native layout pass forStackScreen.Changes
needsCustomLayoutForChildren=trueinStackHostViewManagerBefore & after - visual documentation
before_orientation.mp4
after_orientation.mp4
Test plan
Run
test-stack-toolbar-menu-show-as-action. Change orientation portrait -> landscape -> portrait multiple times. The content of the screen should be laid out correctly.Checklist