Skip to content

Commit

Permalink
fix onSubmitted not triggered when returnKeyType specified (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
henryleunghk authored Dec 4, 2021
1 parent e4e9d8e commit 50862ad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions example/lib/more_use_case_listing_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class _MoreUseCaseListingPageState extends State<MoreUseCaseListingPage> {
child: NativeTextInput(
minLines: 3,
maxLines: 5,
returnKeyType: ReturnKeyType.done,
onChanged: _onChangeText,
onSubmitted: _onSubmittedText,
)),
Expand Down
4 changes: 2 additions & 2 deletions ios/Classes/NativeTextInputDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 50862ad

Please sign in to comment.