Android: Fix useWindowDimensions not updating on Android 15 foldables #53467
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.
ReactRootView now listens to
WindowInfoTrackerevents on Android 15+ to handle fold/unfold state changes. Previously,useWindowDimensionsrelied only on configuration changes, which are not always triggered on Android 15. This caused incorrect width/height values on foldable devices.The new listener recalculates display metrics and emits
didUpdateDimensionsto JS, restoring correct behavior.Fixes #47080
Summary
On Android 15 foldables,
useWindowDimensionsdoes not update after fold/unfold because no configuration change is triggered. This PR introduces aWindowInfoTrackerlistener inReactRootViewto detect these window layout changes and emit updated display metrics to JavaScript. This restores correct dimension reporting in apps.Changelog
[ANDROID] [FIXED] - Fix
useWindowDimensionsnot updating on Android 15 foldables by listening toWindowInfoTrackerevents inReactRootViewTest Plan
useWindowDimensions.didUpdateDimensionsevent is emitted and JS receives the new width/height values.