Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix onSubmitEditing not being called on single-line TextInput #458

Merged

Conversation

tido64
Copy link
Member

@tido64 tido64 commented Jun 18, 2020

  • I am removing an existing difference between facebook/react-native and microsoft/react-native-macos 👍
  • I am cherry-picking a change from Facebook's react-native into microsoft/react-native-macos 👍
  • I am making a fix / change for the macOS implementation of react-native
  • I am making a change required for Microsoft usage of react-native

Summary

onSubmitEditing does not get called when pressing Enter in single-line TextInput.

Resolves #451

Changelog

[macOS] [Fixed] - Fix onSubmitEditing not being called on single-line TextInput

Test Plan

textinput-single-submit

Microsoft Reviewers: Open in CodeFlow

@tido64 tido64 requested a review from tom-un as a code owner June 18, 2020 09:43
@tom-un
Copy link
Collaborator

tom-un commented Jun 18, 2020

Thanks for this! I was testing this change and noticed that multiline textinput is also not getting this event:

multiline blur

In iOS, when a multiline textinput gets the return key, the following callstack happens:

Calls [_eventDispatcher sendTextEventWithType:RCTTextEventTypeSubmit …]
-[RCTBaseTextInputView textInputShouldReturn] 
-[RCTBackedTextViewDelegateAdapter textView:shouldChangeTextInRange:replacementText:]

Similarly, for a single line textinput:

Calls [_eventDispatcher sendTextEventWithType:RCTTextEventTypeSubmit …]
-[RCTBaseTextInputView textInputShouldReturn] 
-[RCTBackedTextFieldDelegateAdapter textFieldShouldReturn:]

When macOS multiline return is pressed the following:

/* #ifdef’d out call to [_backedTextInputView.textInputDelegate textInputShouldReturn] */
-[RCTBackedTextViewDelegateAdapter textView:shouldChangeTextInRange:replacementText:] 
-[RCTBackedTextViewDelegateAdapter textView:shouldChangeTextInRange:replacementString:]

I don't know why the entire block of code that calls [_backedTextInputView.textInputDelegate textInputShouldReturn] is excluded for mac. Either it could be restored or an #else clause for mac could do a variant.

thanks!

@tido64
Copy link
Member Author

tido64 commented Jun 18, 2020

I was testing this change and noticed that multiline textinput is also not getting this event

On multiline TextInput, you're supposed to press Cmd+Enter. We changed it in #442 to allow users to input newlines.

@tido64
Copy link
Member Author

tido64 commented Jun 19, 2020

@tom-un: I checked with Eli and upstream. The Android behaviour is to be considered canonical. I've submitted a PR to re-align: #463. At the same time, I will also fix the iOS behaviour upstream as it also wrong.

This PR, however, should be good to go provided you don't find any issues.

@tom-un
Copy link
Collaborator

tom-un commented Jun 19, 2020

Thanks for ironing out the expected behavior and making sure all the platforms are in alignment!

@tom-un tom-un merged commit d68e94b into microsoft:master Jun 19, 2020
@tido64 tido64 deleted the fix-single-line-TextInput-onSubmitEditing branch June 19, 2020 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Single line TextInput onSubmitEditing doesn't work
2 participants