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

Commit 789a549

Browse files
authored
[macos] Move TextInputPlugin outside of visible area (#39031)
* [macos] Move TextInputPlugin outside of visible area * Make plugin empty and add test
1 parent d17004d commit 789a549

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,4 +1532,20 @@ - (bool)testSelectorsAreForwardedToFramework {
15321532
ASSERT_FALSE(window.firstResponder == viewController.textInputPlugin);
15331533
}
15341534

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

0 commit comments

Comments
 (0)