You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit df7b9a2
Browse filesBrowse the repository at this point in the historyBrowse files
Report font scale changes to JS while the host stays resumed
Summary:
`DeviceInfoModule` caches the font scale and re-reads it only in `onHostResume`. When the system font scale changes while the app stays resumed, `ReactHostImpl.onConfigurationChanged` re-lays out the native views at the new scale, but JS never receives `didUpdateDimensions`. `Dimensions`, `useWindowDimensions().fontScale` and `PixelRatio.getFontScale()` keep the old value, so a JS layout that multiplies by the font scale clips text that has already grown natively.
An app stays resumed through a font scale change when it is visible next to the system settings, for example in multi-window. `ReactHostImpl.onConfigurationChanged` now asks `DeviceInfoModule` to re-read the font scale, and the module emits `didUpdateDimensions` when the value changed.
Changelog:
[Android][Fixed] - Emit `didUpdateDimensions` when the font scale changes while the app stays resumed
Reviewed By: javache
Differential Revision: D135575916
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/DeviceInfoModule.kt
+7Lines changed: 7 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -116,6 +116,13 @@ internal class DeviceInfoModule(reactContext: ReactApplicationContext) :
116
116
}
117
117
118
118
overridefunonHostResume() {
119
+
updateFontScale()
120
+
}
121
+
122
+
/**
123
+
* Re-reads the font scale from the configuration and emits `didUpdateDimensions` if it changed.
124
+
*/
125
+
funupdateFontScale() {
119
126
val newFontScale = reactApplicationContext.resources?.configuration?.fontScale
120
127
if (newFontScale !=null&& newFontScale != fontScale) {
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/deviceinfo/DeviceInfoModuleTest.kt
0 commit comments