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

Align multi-line TextInput onSubmitEditing with Android #463

Merged
merged 1 commit into from
Jun 19, 2020

Conversation

tido64
Copy link
Member

@tido64 tido64 commented Jun 19, 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

The current multi-line TextInput onSubmitEditing behaviour in macOS deviates from upstream.

Setting blurOnSubmit to true means that pressing return will blur
the field and trigger the onSubmitEditing event instead of inserting
a newline into the field.

-- https://reactnative.dev/docs/textinput#bluronsubmit

Changelog

[macOS] [Fixed] - Align multi-line TextInput onSubmitEditing with Android

Test Plan

  1. Go to RNTester > TextInput
  2. Search for "submit"
  3. Enter something in the multi-line TextInput and press enter
  4. An alert should appear and no newline is inserted
  5. Modify the example to set onSubmitEditing=false (patch provided below)
  6. Repeat step 1-3, no alert should appear and newlines should be inserted
diff --git a/RNTester/js/examples/TextInput/TextInputExample.ios.js b/RNTester/js/examples/TextInput/TextInputExample.ios.js
index f21ca72d3..9e07c903b 100644
--- a/RNTester/js/examples/TextInput/TextInputExample.ios.js
+++ b/RNTester/js/examples/TextInput/TextInputExample.ios.js
@@ -898,9 +898,9 @@ exports.examples = [
         <View>
           <TextInput
             style={styles.multiline}
-            placeholder="blurOnSubmit = true"
+            placeholder="blurOnSubmit = false"
             returnKeyType="next"
-            blurOnSubmit={true}
+            blurOnSubmit={false}
             multiline={true}
             onSubmitEditing={event =>
               Alert.alert('Alert', event.nativeEvent.text)
Microsoft Reviewers: Open in CodeFlow

Setting `blurOnSubmit` to `true` means that pressing return will blur
the field and trigger the `onSubmitEditing` event instead of inserting
a newline into the field.

-- https://reactnative.dev/docs/textinput#bluronsubmit
Comment on lines +410 to +420
#if TARGET_OS_OSX // [TODO(macOS Candidate ISS#2710739)
if (_blurOnSubmit) {
#endif // ]TODO(macOS Candidate ISS#2710739)
[_eventDispatcher sendTextEventWithType:RCTTextEventTypeSubmit
reactTag:self.reactTag
text:self.backedTextInputView.attributedText.string
key:nil
eventCount:_nativeEventCount];
#if TARGET_OS_OSX // [TODO(macOS Candidate ISS#2710739)
}
#endif // ]TODO(macOS Candidate ISS#2710739)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upstream: facebook#29177

@tom-un tom-un merged commit 2803dc8 into microsoft:master Jun 19, 2020
@tido64 tido64 deleted the align-multiline-textinput-android 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.

2 participants