[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:
Bruno Leroux
2023-09-22 08:00:58 +02:00
committed by GitHub
parent df178c897b
commit 87139861e6
2 changed files with 22 additions and 3 deletions

View File

@@ -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 = @"";

View File

@@ -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];