Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c6eda8c

Browse files
committed
Reland "[macos] Move TextInputPlugin outside of visible area"
1 parent 189a69d commit c6eda8c

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
@@ -245,8 +245,9 @@ @implementation FlutterTextInputPlugin {
245245
}
246246

247247
- (instancetype)initWithViewController:(FlutterViewController*)viewController {
248-
// The view needs a non-zero frame.
249-
self = [super initWithFrame:NSMakeRect(0, 0, 1, 1)];
248+
// The view needs an empty frame otherwise it is visible on dark background.
249+
// https://github.com/flutter/flutter/issues/118504
250+
self = [super initWithFrame:NSZeroRect];
250251
if (self != nil) {
251252
_flutterViewController = viewController;
252253
_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
@@ -1532,4 +1532,21 @@ - (bool)testSelectorsAreForwardedToFramework {
15321532
ASSERT_FALSE(window.firstResponder == viewController.textInputPlugin);
15331533
}
15341534

1535+
TEST(FlutterTextInputPluginTest, HasZeroSize) {
1536+
id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
1537+
id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
1538+
OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
1539+
[engineMock binaryMessenger])
1540+
.andReturn(binaryMessengerMock);
1541+
1542+
FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
1543+
nibName:@""
1544+
bundle:nil];
1545+
1546+
FlutterTextInputPlugin* plugin =
1547+
[[FlutterTextInputPlugin alloc] initWithViewController:viewController];
1548+
1549+
ASSERT_TRUE(NSIsEmptyRect(plugin.frame));
1550+
}
1551+
15351552
} // namespace flutter::testing

0 commit comments

Comments
 (0)