Skip to content

Commit 2bda4b1

Browse files
authored
fix(0.77): dismiss all sheets created by RCTDevLoadingView when hide is called (#2457)
Backport of #2448 to 0.77-stable
1 parent 952b164 commit 2bda4b1

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
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.77.2",
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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2753,7 +2753,7 @@ __metadata:
27532753
languageName: unknown
27542754
linkType: soft
27552755

2756-
"@react-native-mac/virtualized-lists@npm:0.77.1, @react-native-mac/virtualized-lists@workspace:packages/virtualized-lists":
2756+
"@react-native-mac/virtualized-lists@npm:0.77.2, @react-native-mac/virtualized-lists@workspace:packages/virtualized-lists":
27572757
version: 0.0.0-use.local
27582758
resolution: "@react-native-mac/virtualized-lists@workspace:packages/virtualized-lists"
27592759
dependencies:
@@ -3048,13 +3048,13 @@ __metadata:
30483048
languageName: unknown
30493049
linkType: soft
30503050

3051-
"@react-native/oss-library-example@npm:0.77.2, @react-native/oss-library-example@workspace:packages/react-native-test-library":
3051+
"@react-native/oss-library-example@workspace:*, @react-native/oss-library-example@workspace:packages/react-native-test-library":
30523052
version: 0.0.0-use.local
30533053
resolution: "@react-native/oss-library-example@workspace:packages/react-native-test-library"
30543054
dependencies:
30553055
"@babel/core": "npm:^7.25.2"
30563056
"@react-native/babel-preset": "npm:0.77.0"
3057-
react-native-macos: "npm:0.77.1"
3057+
react-native-macos: "npm:0.77.2"
30583058
peerDependencies:
30593059
react: "*"
30603060
react-native-macos: "*"
@@ -3097,7 +3097,7 @@ __metadata:
30973097
"@react-native-community/cli": "npm:15.0.0-alpha.2"
30983098
"@react-native-community/cli-platform-android": "npm:15.0.0-alpha.2"
30993099
"@react-native-community/cli-platform-ios": "npm:15.0.0-alpha.2"
3100-
"@react-native/oss-library-example": "npm:0.77.2"
3100+
"@react-native/oss-library-example": "workspace:*"
31013101
"@react-native/popup-menu-android": "workspace:*"
31023102
flow-enums-runtime: "npm:^0.0.6"
31033103
invariant: "npm:^2.2.4"
@@ -10873,12 +10873,12 @@ __metadata:
1087310873
languageName: unknown
1087410874
linkType: soft
1087510875

10876-
"react-native-macos@npm:0.77.1, react-native-macos@workspace:packages/react-native":
10876+
"react-native-macos@npm:0.77.2, react-native-macos@workspace:packages/react-native":
1087710877
version: 0.0.0-use.local
1087810878
resolution: "react-native-macos@workspace:packages/react-native"
1087910879
dependencies:
1088010880
"@jest/create-cache-key-function": "npm:^29.6.3"
10881-
"@react-native-mac/virtualized-lists": "npm:0.77.1"
10881+
"@react-native-mac/virtualized-lists": "npm:0.77.2"
1088210882
"@react-native/assets-registry": "npm:0.77.0"
1088310883
"@react-native/codegen": "npm:0.77.0"
1088410884
"@react-native/community-cli-plugin": "npm:0.77.0"

0 commit comments

Comments
 (0)