Skip to content

Commit 84f8c9a

Browse files
vincentriemerfacebook-github-bot
authored andcommitted
Ensure LogBoxView is sized based on the "window" size instead of the "screen" size
Summary: In iOS, the native LogBox that gets rendered for JS errors/warnings is statically sized once and bases that size off of the entire screen's size. This causes issues when being run in a Mac Catalyst app since 1) the sizing is not static since we can resize the window and 2) the size of the LogBox's root should fill the *window* and not the screen. This diff fixes both of these issues. Changelog: [iOS][Fixed] - Ensure LogBoxView is sized relative to the key window instead of the full screen Reviewed By: appden Differential Revision: D34697076 fbshipit-source-id: 9665fd51bc86ed29837672cec882bac97904b0c8
1 parent 5386364 commit 84f8c9a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

React/CoreModules/RCTLogBox.mm

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ + (BOOL)requiresMainQueueSetup
5151

5252
if (strongSelf->_bridge) {
5353
if (strongSelf->_bridge.valid) {
54-
strongSelf->_view = [[RCTLogBoxView alloc] initWithFrame:[UIScreen mainScreen].bounds
55-
bridge:strongSelf->_bridge];
54+
strongSelf->_view = [[RCTLogBoxView alloc] initWithFrame:RCTKeyWindow().frame bridge:strongSelf->_bridge];
5655
[strongSelf->_view show];
5756
}
5857
} else {

React/CoreModules/RCTLogBoxView.mm

+7-2
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ - (instancetype)initWithFrame:(CGRect)frame bridge:(RCTBridge *)bridge
3939
self.backgroundColor = [UIColor clearColor];
4040

4141
_surface = [[RCTSurface alloc] initWithBridge:bridge moduleName:@"LogBox" initialProperties:@{}];
42-
43-
[_surface start];
4442
[_surface setSize:frame.size];
43+
[_surface start];
4544

4645
if (![_surface synchronouslyWaitForStage:RCTSurfaceStageSurfaceDidInitialMounting timeout:1]) {
4746
RCTLogInfo(@"Failed to mount LogBox within 1s");
@@ -52,6 +51,12 @@ - (instancetype)initWithFrame:(CGRect)frame bridge:(RCTBridge *)bridge
5251
return self;
5352
}
5453

54+
- (void)layoutSubviews
55+
{
56+
[super layoutSubviews];
57+
[_surface setSize:self.frame.size];
58+
}
59+
5560
- (void)dealloc
5661
{
5762
[RCTSharedApplication().delegate.window makeKeyWindow];

0 commit comments

Comments
 (0)