react-native
react-native copied to clipboard
fix: return the correct default trait collection
Summary:
Currently, when the _currentColorScheme
is nil the default comes from [UITraitCollection currentTraitCollection]
which provides the trait collection of the context it was called in. Generally, this will work but in some cases the context can be different and this will return the wrong value also if the Appearance
property is set in the plist, then initially that value is returned, regardless of if you have overridden it. Seen as the userInterfaceStyle
of the window is overridden when the value is changed, then the default should be whatever the current style of the window is and not dependent on the calling context.
Before | After |
---|---|
Changelog:
[IOS] [FIXED] - Fix the default trait collection to always return the value of the window
Test Plan:
Tested on rn-tester and verified the current behaviour is unaffected and also in our own repo to make sure it addresses the problem. Video provided above
Platform | Engine | Arch | Size (bytes) | Diff |
---|---|---|---|---|
android | hermes | arm64-v8a | 9,061,546 | +4 |
android | hermes | armeabi-v7a | 8,310,881 | +3 |
android | hermes | x86 | 9,577,764 | +2 |
android | hermes | x86_64 | 9,420,185 | +3 |
android | jsc | arm64-v8a | 9,613,324 | +5 |
android | jsc | armeabi-v7a | 8,739,959 | +5 |
android | jsc | x86 | 9,700,289 | +2 |
android | jsc | x86_64 | 9,946,838 | -1 |
Base commit: 41477c898cf5726eae9edbb1596366a6eea2b01e Branch: main
Thanks for the review @cipolleschi Sorry for the delay. I've made the changes
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
This pull request was successfully merged by @alanjhughes in 94fea182d6cf19e96a8a87760017bd69ad0a9e0c.
When will my fix make it into a release? | Upcoming Releases
This pull request has been reverted by 7888338295476f4d4f00733309e54b8d22318e1e.
#39439