Skip to content

Commit c695eb6

Browse files
authored
fix(0.78): dismiss all sheets created by RCTDevLoadingView when hide is called (#2458)
Backport of #2448 to 0.78-stable
1 parent d5b0325 commit c695eb6

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

packages/react-native/React/CoreModules/RCTDevLoadingView.mm

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
using namespace facebook::react;
2626

27+
static NSString *sRCTDevLoadingViewWindowIdentifier = @"RCTDevLoadingViewWindow";
28+
2729
@interface RCTDevLoadingView () <NativeDevLoadingViewSpec>
2830
@end
2931

@@ -121,16 +123,17 @@ - (void)showMessage:(NSString *)message color:(RCTUIColor *)color backgroundColo
121123

122124
self->_showDate = [NSDate date];
123125

124-
RCTPlatformWindow *mainWindow = RCTKeyWindow(); // [macOS]
125126
#if !TARGET_OS_OSX // [macOS]
127+
UIWindow *mainWindow = RCTKeyWindow();
126128
self->_window = [[UIWindow alloc] initWithWindowScene:mainWindow.windowScene];
127129
self->_window.windowLevel = UIWindowLevelStatusBar + 1;
128130
self->_window.rootViewController = [UIViewController new];
129131
#else // [macOS
130-
self->_window = [[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, 375, 20)
132+
self->_window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 375, 20)
131133
styleMask:NSWindowStyleMaskBorderless
132134
backing:NSBackingStoreBuffered
133135
defer:YES];
136+
[self->_window setIdentifier:sRCTDevLoadingViewWindowIdentifier];
134137
#endif // macOS]
135138

136139
self->_container = [[RCTUIView alloc] init]; // [macOS]
@@ -220,7 +223,11 @@ - (void)showMessage:(NSString *)message color:(RCTUIColor *)color backgroundColo
220223
self->_hiding = false;
221224
}];
222225
#else // [macOS]
223-
[RCTKeyWindow() endSheet:self->_window];
226+
for (NSWindow *window in [RCTKeyWindow() sheets]) {
227+
if ([[window identifier] isEqualToString:sRCTDevLoadingViewWindowIdentifier]) {
228+
[RCTKeyWindow() endSheet:window];
229+
}
230+
}
224231
self->_window = nil;
225232
self->_hiding = false;
226233
#endif // macOS]
@@ -350,4 +357,4 @@ - (void)hide
350357
Class RCTDevLoadingViewCls(void)
351358
{
352359
return RCTDevLoadingView.class;
353-
}
360+
}

packages/rn-tester/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"e2e-test-ios": "./scripts/maestro-test-ios.sh"
2828
},
2929
"dependencies": {
30-
"@react-native/oss-library-example": "0.78.3",
30+
"@react-native/oss-library-example": "workspace:*",
3131
"@react-native/popup-menu-android": "workspace:*",
3232
"flow-enums-runtime": "^0.0.6",
3333
"invariant": "^2.2.4",

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2755,7 +2755,7 @@ __metadata:
27552755
languageName: unknown
27562756
linkType: soft
27572757

2758-
"@react-native-mac/virtualized-lists@npm:0.77.3, @react-native-mac/virtualized-lists@workspace:packages/virtualized-lists":
2758+
"@react-native-mac/virtualized-lists@npm:0.78.2, @react-native-mac/virtualized-lists@workspace:packages/virtualized-lists":
27592759
version: 0.0.0-use.local
27602760
resolution: "@react-native-mac/virtualized-lists@workspace:packages/virtualized-lists"
27612761
dependencies:
@@ -3060,7 +3060,7 @@ __metadata:
30603060
languageName: unknown
30613061
linkType: soft
30623062

3063-
"@react-native/oss-library-example@npm:0.78.3, @react-native/oss-library-example@workspace:packages/react-native-test-library":
3063+
"@react-native/oss-library-example@workspace:*, @react-native/oss-library-example@workspace:packages/react-native-test-library":
30643064
version: 0.0.0-use.local
30653065
resolution: "@react-native/oss-library-example@workspace:packages/react-native-test-library"
30663066
dependencies:
@@ -3096,7 +3096,7 @@ __metadata:
30963096
"@react-native-community/cli": "npm:15.0.0-alpha.2"
30973097
"@react-native-community/cli-platform-android": "npm:15.0.0-alpha.2"
30983098
"@react-native-community/cli-platform-ios": "npm:15.0.0-alpha.2"
3099-
"@react-native/oss-library-example": "npm:0.78.3"
3099+
"@react-native/oss-library-example": "workspace:*"
31003100
"@react-native/popup-menu-android": "workspace:*"
31013101
flow-enums-runtime: "npm:^0.0.6"
31023102
invariant: "npm:^2.2.4"
@@ -10865,7 +10865,7 @@ __metadata:
1086510865
resolution: "react-native-macos@workspace:packages/react-native"
1086610866
dependencies:
1086710867
"@jest/create-cache-key-function": "npm:^29.6.3"
10868-
"@react-native-mac/virtualized-lists": "npm:0.77.3"
10868+
"@react-native-mac/virtualized-lists": "npm:0.78.2"
1086910869
"@react-native/assets-registry": "npm:0.78.1"
1087010870
"@react-native/codegen": "npm:0.78.1"
1087110871
"@react-native/community-cli-plugin": "npm:0.78.1"

0 commit comments

Comments
 (0)