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

Commit fcda558

Browse files
committed
[ios17]Do not notify text change in iOS 17 after setting selection rects
1 parent 17a711a commit fcda558

File tree

2 files changed

+3
-46
lines changed

2 files changed

+3
-46
lines changed

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

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,21 +2380,10 @@ - (void)setSelectionRects:(NSArray*)encodedRects {
23802380
: NSWritingDirectionRightToLeft]];
23812381
}
23822382

2383-
BOOL shouldNotifyTextChange = NO;
2384-
if (@available(iOS 17, *)) {
2385-
// Force UIKit to query the selectionRects again on iOS 17+
2386-
// This is to fix a bug on iOS 17+ where UIKit queries the outdated selectionRects after
2387-
// entering a character, resulting in auto-correction highlight region missing the last
2388-
// character.
2389-
shouldNotifyTextChange = YES;
2390-
}
2391-
if (shouldNotifyTextChange) {
2392-
[_activeView.inputDelegate textWillChange:_activeView];
2393-
}
2383+
// TODO(hellohuanlin): Investigate why notifying the text input system about text changes (via
2384+
// textWillChange and textDidChange APIs) causes a bug where we cannot enter text with IME
2385+
// keyboards. Issue: https://github.com/flutter/flutter/issues/133908
23942386
_activeView.selectionRects = rectsAsRect;
2395-
if (shouldNotifyTextChange) {
2396-
[_activeView.inputDelegate textDidChange:_activeView];
2397-
}
23982387
}
23992388

24002389
- (void)startLiveTextInput {

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

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -436,38 +436,6 @@ - (void)testInputHiderOverlapWithTextWhenScribbleIsDisabledAfterIOS17AndDoesNotO
436436
}
437437
}
438438

439-
- (void)testSetSelectionRectsNotifiesTextChangeAfterIOS17AndDoesNotNotifyBeforeIOS17 {
440-
FlutterTextInputPlugin* myInputPlugin =
441-
[[FlutterTextInputPlugin alloc] initWithDelegate:OCMClassMock([FlutterEngine class])];
442-
443-
FlutterMethodCall* setClientCall =
444-
[FlutterMethodCall methodCallWithMethodName:@"TextInput.setClient"
445-
arguments:@[ @(123), self.mutableTemplateCopy ]];
446-
[myInputPlugin handleMethodCall:setClientCall
447-
result:^(id _Nullable result){
448-
}];
449-
450-
id mockInputDelegate = OCMProtocolMock(@protocol(UITextInputDelegate));
451-
myInputPlugin.activeView.inputDelegate = mockInputDelegate;
452-
453-
NSArray<NSNumber*>* selectionRect = [NSArray arrayWithObjects:@0, @0, @100, @100, @0, @1, nil];
454-
NSArray* selectionRects = [NSArray arrayWithObjects:selectionRect, nil];
455-
FlutterMethodCall* methodCall =
456-
[FlutterMethodCall methodCallWithMethodName:@"Scribble.setSelectionRects"
457-
arguments:selectionRects];
458-
[myInputPlugin handleMethodCall:methodCall
459-
result:^(id _Nullable result){
460-
}];
461-
462-
if (@available(iOS 17.0, *)) {
463-
OCMVerify([mockInputDelegate textWillChange:myInputPlugin.activeView]);
464-
OCMVerify([mockInputDelegate textDidChange:myInputPlugin.activeView]);
465-
} else {
466-
OCMVerify(never(), [mockInputDelegate textWillChange:myInputPlugin.activeView]);
467-
OCMVerify(never(), [mockInputDelegate textDidChange:myInputPlugin.activeView]);
468-
}
469-
}
470-
471439
- (void)testTextRangeFromPositionMatchesUITextViewBehavior {
472440
FlutterTextInputView* inputView = [[FlutterTextInputView alloc] initWithOwner:textInputPlugin];
473441
FlutterTextPosition* fromPosition = [FlutterTextPosition positionWithIndex:2];

0 commit comments

Comments
 (0)