Skip to content

Commit

Permalink
[CherryPick] Fix retrieving current appearance in multi-window apps (#…
Browse files Browse the repository at this point in the history
…2125)

## Summary:

Cherry pick
facebook@d00d35e
to fix a bug we're seeing internally

## Test Plan:

CI should pass
  • Loading branch information
Saadnajmi authored May 22, 2024
2 parents bb2770d + 30336ea commit 2954e4f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions packages/react-native/React/CoreModules/RCTAlertController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ - (void)show:(BOOL)animated completion:(void (^)(void))completion
{
UIUserInterfaceStyle style = self.overrideUserInterfaceStyle;
if (style == UIUserInterfaceStyleUnspecified) {
style = RCTSharedApplication().delegate.window.overrideUserInterfaceStyle
? RCTSharedApplication().delegate.window.overrideUserInterfaceStyle
: UIUserInterfaceStyleUnspecified;
UIUserInterfaceStyle overriddenStyle = RCTKeyWindow().overrideUserInterfaceStyle;
style = overriddenStyle ? overriddenStyle : UIUserInterfaceStyleUnspecified;
}

self.overrideUserInterfaceStyle = style;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React/CoreModules/RCTAppearance.mm
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ - (instancetype)init
{
if ((self = [super init])) {
#if !TARGET_OS_OSX // [macOS]
UITraitCollection *traitCollection = RCTSharedApplication().delegate.window.traitCollection;
UITraitCollection *traitCollection = RCTKeyWindow().traitCollection;
_currentColorScheme = RCTColorSchemePreference(traitCollection);
#else // [macOS
NSAppearance *appearance = RCTSharedApplication().appearance;
Expand Down

0 comments on commit 2954e4f

Please sign in to comment.