Skip to content

Commit 02a0e7c

Browse files
knopp0xZOne
authored andcommitted
Reland "[macos] Move TextInputPlugin outside of visible area" (flutter#39194)
1 parent f3a26d6 commit 02a0e7c

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,9 @@ @implementation FlutterTextInputPlugin {
303303
}
304304

305305
- (instancetype)initWithViewController:(FlutterViewController*)viewController {
306-
// The view needs a non-zero frame.
307-
self = [super initWithFrame:NSMakeRect(0, 0, 1, 1)];
306+
// The view needs an empty frame otherwise it is visible on dark background.
307+
// https://github.com/flutter/flutter/issues/118504
308+
self = [super initWithFrame:NSZeroRect];
308309
if (self != nil) {
309310
_flutterViewController = viewController;
310311
_channel = [FlutterMethodChannel methodChannelWithName:kTextInputChannel

shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,4 +1778,21 @@ - (bool)testSelectorsAreForwardedToFramework {
17781778
ASSERT_FALSE(window.firstResponder == viewController.textInputPlugin);
17791779
}
17801780

1781+
TEST(FlutterTextInputPluginTest, HasZeroSize) {
1782+
id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
1783+
id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
1784+
OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
1785+
[engineMock binaryMessenger])
1786+
.andReturn(binaryMessengerMock);
1787+
1788+
FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
1789+
nibName:@""
1790+
bundle:nil];
1791+
1792+
FlutterTextInputPlugin* plugin =
1793+
[[FlutterTextInputPlugin alloc] initWithViewController:viewController];
1794+
1795+
ASSERT_TRUE(NSIsEmptyRect(plugin.frame));
1796+
}
1797+
17811798
} // namespace flutter::testing

0 commit comments

Comments
 (0)