From b654815f52c3135084bc5feaaada87b5fba93868 Mon Sep 17 00:00:00 2001 From: "jan.swiezynski" <62596588+jan-swiezynski@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:05:02 +0100 Subject: [PATCH] [iOS] option to enable suggestions with autocorrect off --- .../framework/Source/FlutterTextInputPlugin.mm | 5 ++++- .../Source/FlutterTextInputPluginTest.mm | 17 ----------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 9358431cf5a6f..1549e249a3e8d 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -78,6 +78,7 @@ static NSString* const kAutofillHints = @"hints"; static NSString* const kAutocorrectionType = @"autocorrect"; +static NSString* const kEnableSuggestions = @"enableSuggestions"; #pragma mark - Static Functions @@ -934,8 +935,10 @@ - (void)configureWithDictionary:(NSDictionary*)configuration { bool autocorrectIsDisabled = autocorrect && ![autocorrect boolValue]; self.autocorrectionType = autocorrectIsDisabled ? UITextAutocorrectionTypeNo : UITextAutocorrectionTypeDefault; + NSString* enableSuggestions = configuration[kEnableSuggestions]; + bool disableSuggestions = enableSuggestions && ![enableSuggestions boolValue]; self.spellCheckingType = - autocorrectIsDisabled ? UITextSpellCheckingTypeNo : UITextSpellCheckingTypeDefault; + disableSuggestions ? UITextSpellCheckingTypeNo : UITextSpellCheckingTypeDefault; self.autofillId = AutofillIdFromDictionary(configuration); if (autofill == nil) { self.textContentType = @""; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm index be00f6e1e63d4..db110e36a7b02 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm @@ -810,23 +810,6 @@ - (void)testInputActionContinueAction { 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); -} - - (void)testReplaceTestLocalAdjustSelectionAndMarkedTextRange { FlutterTextInputView* inputView = [[FlutterTextInputView alloc] initWithOwner:textInputPlugin]; [inputView setMarkedText:@"test text" selectedRange:NSMakeRange(0, 5)];