Skip to content

Commit

Permalink
[macOS] FlutterTextInputPlugin should clip to bounds (#46142)
Browse files Browse the repository at this point in the history
  • Loading branch information
knopp authored Sep 28, 2023
1 parent ae3ae78 commit cc7c3c1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 9,11 @@

@class FlutterTextField;

@interface NSView (ClipsToBounds)
// This property is available since macOS 10.9 but only declared in macOS 14 SDK.
@property BOOL clipsToBounds API_AVAILABLE(macos(10.9));
@end

/**
* A plugin to handle text input.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 342,7 @@ - (instancetype)initWithViewController:(FlutterViewController*)viewController {
// The view needs an empty frame otherwise it is visible on dark background.
// https://github.com/flutter/flutter/issues/118504
self = [super initWithFrame:NSZeroRect];
self.clipsToBounds = YES;
if (self != nil) {
_flutterViewController = viewController;
_channel = [FlutterMethodChannel methodChannelWithName:kTextInputChannel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1962,7 1962,7 @@ - (bool)testSelectorsAreForwardedToFramework {
ASSERT_FALSE(window.firstResponder == viewController.textInputPlugin);
}

TEST(FlutterTextInputPluginTest, HasZeroSize) {
TEST(FlutterTextInputPluginTest, HasZeroSizeAndClipsToBounds) {
id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
Expand All @@ -1977,6 1977,7 @@ - (bool)testSelectorsAreForwardedToFramework {
[[FlutterTextInputPlugin alloc] initWithViewController:viewController];

ASSERT_TRUE(NSIsEmptyRect(plugin.frame));
ASSERT_TRUE(plugin.clipsToBounds);
}

} // namespace flutter::testing

0 comments on commit cc7c3c1

Please sign in to comment.