[iOS] Disable spelling corrections when auto correction is disabled (flutter/engine#46144)
## Description This iOS PR disables spellchecking when auto correction is disabled. ## Related Issue Fixes https://github.com/flutter/flutter/issues/134881. ## Tests Adds 1 test.
This commit is contained in:
@@ -878,9 +878,11 @@ static BOOL IsSelectionRectBoundaryCloserToPoint(CGPoint point,
|
||||
self.keyboardAppearance = UIKeyboardAppearanceDefault;
|
||||
}
|
||||
NSString* autocorrect = configuration[kAutocorrectionType];
|
||||
self.autocorrectionType = autocorrect && ![autocorrect boolValue]
|
||||
? UITextAutocorrectionTypeNo
|
||||
: UITextAutocorrectionTypeDefault;
|
||||
bool autocorrectIsDisabled = autocorrect && ![autocorrect boolValue];
|
||||
self.autocorrectionType =
|
||||
autocorrectIsDisabled ? UITextAutocorrectionTypeNo : UITextAutocorrectionTypeDefault;
|
||||
self.spellCheckingType =
|
||||
autocorrectIsDisabled ? UITextSpellCheckingTypeNo : UITextSpellCheckingTypeDefault;
|
||||
self.autofillId = AutofillIdFromDictionary(configuration);
|
||||
if (autofill == nil) {
|
||||
self.textContentType = @"";
|
||||
|
||||
@@ -769,6 +769,23 @@ FLUTTER_ASSERT_ARC
|
||||
OCMVerify([mockBinaryMessenger sendOnChannel:@"flutter/textinput" message:encodedMethodCall]);
|
||||
}
|
||||
|
||||
- (void)testDisablingAutocorrectDisablesSpellChecking {
|
||||
FlutterTextInputView* inputView = [[FlutterTextInputView alloc] initWithOwner:textInputPlugin];
|
||||
|
||||
// Disable the interactive selection.
|
||||
NSDictionary* config = self.mutableTemplateCopy;
|
||||
[inputView configureWithDictionary:config];
|
||||
|
||||
XCTAssertEqual(inputView.autocorrectionType, UITextAutocorrectionTypeDefault);
|
||||
XCTAssertEqual(inputView.spellCheckingType, UITextSpellCheckingTypeDefault);
|
||||
|
||||
[config setValue:@(NO) forKey:@"autocorrect"];
|
||||
[inputView configureWithDictionary:config];
|
||||
|
||||
XCTAssertEqual(inputView.autocorrectionType, UITextAutocorrectionTypeNo);
|
||||
XCTAssertEqual(inputView.spellCheckingType, UITextSpellCheckingTypeNo);
|
||||
}
|
||||
|
||||
#pragma mark - TextEditingDelta tests
|
||||
- (void)testTextEditingDeltasAreGeneratedOnTextInput {
|
||||
FlutterTextInputView* inputView = [[FlutterTextInputView alloc] initWithOwner:textInputPlugin];
|
||||
|
||||
Reference in New Issue
Block a user