diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index f02ab85da7..e2fe1334ff 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -902,7 +902,14 @@ static BOOL IsSelectionRectBoundaryCloserToPoint(CGPoint point, // Prevent UIKit from showing selection handles or highlights. This is needed // because Scribble interactions require the view to have it's actual frame on -// the screen. +// the screen. They're not needed on iOS 17 with the new +// UITextSelectionDisplayInteraction API. +// +// These are undocumented methods. On iOS 17, the insertion point color is also +// used as the highlighted background of the selected IME candidate: +// https://github.com/flutter/flutter/issues/132548 +// So the respondsToSelector method is overridden to return NO for this method +// on iOS 17+. - (UIColor*)insertionPointColor { return [UIColor clearColor]; } @@ -930,6 +937,16 @@ static BOOL IsSelectionRectBoundaryCloserToPoint(CGPoint point, return _textInputPlugin.textInputDelegate; } +- (BOOL)respondsToSelector:(SEL)selector { + if (@available(iOS 17.0, *)) { + // See the comment on this method. + if (selector == @selector(insertionPointColor)) { + return NO; + } + } + return [super respondsToSelector:selector]; +} + - (void)setTextInputClient:(int)client { _textInputClient = client; _hasPlaceholder = NO; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm index f18357acf0..b4d6dcb7e0 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm @@ -786,6 +786,17 @@ FLUTTER_ASSERT_ARC XCTAssertEqual(inputView.spellCheckingType, UITextSpellCheckingTypeNo); } +- (void)testFlutterTextInputViewOnlyRespondsToInsertionPointColorBelowIOS17 { + FlutterTextInputView* inputView = [[FlutterTextInputView alloc] initWithOwner:textInputPlugin]; + BOOL respondsToInsertionPointColor = + [inputView respondsToSelector:@selector(insertionPointColor)]; + if (@available(iOS 17, *)) { + XCTAssertFalse(respondsToInsertionPointColor); + } else { + XCTAssertTrue(respondsToInsertionPointColor); + } +} + #pragma mark - TextEditingDelta tests - (void)testTextEditingDeltasAreGeneratedOnTextInput { FlutterTextInputView* inputView = [[FlutterTextInputView alloc] initWithOwner:textInputPlugin];