From 50862adc2757d5ca7e8d2b1e8df82eb1604daa55 Mon Sep 17 00:00:00 2001 From: Henry Leung Date: Sat, 4 Dec 2021 14:15:42 +0800 Subject: [PATCH] fix onSubmitted not triggered when returnKeyType specified (#16) --- example/lib/more_use_case_listing_page.dart | 1 + ios/Classes/NativeTextInputDelegate.m | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/example/lib/more_use_case_listing_page.dart b/example/lib/more_use_case_listing_page.dart index bac49be..1bb91d0 100644 --- a/example/lib/more_use_case_listing_page.dart +++ b/example/lib/more_use_case_listing_page.dart @@ -63,6 +63,7 @@ class _MoreUseCaseListingPageState extends State { child: NativeTextInput( minLines: 3, maxLines: 5, + returnKeyType: ReturnKeyType.done, onChanged: _onChangeText, onSubmitted: _onSubmittedText, )), diff --git a/ios/Classes/NativeTextInputDelegate.m b/ios/Classes/NativeTextInputDelegate.m index 63b6f7b..4936ec8 100644 --- a/ios/Classes/NativeTextInputDelegate.m +++ b/ios/Classes/NativeTextInputDelegate.m @@ -136,8 +136,8 @@ - (void)textViewDidEndEditing:(UITextView *)textView { } - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { - if ( - textView.textContainer.maximumNumberOfLines == 1 && + if ((textView.returnKeyType != UIReturnKeyDefault || + textView.textContainer.maximumNumberOfLines == 1) && [text isEqualToString:@"\n"] ) { [textView resignFirstResponder];