Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix onSubmitEditing dispatch behavior with blurOnSubmit/multiline com…
…binations. Summary: Fixes facebook#15863 on master. Behavior of `onSubmitEditing` is now consistent between iOS and Android. Tapping the submit button in a TextInput dispatches the event precisely when doing so does not make a newline (when blurOnSubmit is true or multiline is false). 1. Run this app on iOS and Android: ``` // flow import React, { Component } from 'react'; import { StyleSheet, TextInput, View } from 'react-native'; type State = { toggled: boolean }; type Props = { blurOnSubmit: boolean, multiline: boolean }; class ToggleColorInput extends Component<Props, State> { state: State = { toggled: false }; props: Props; toggle = () => { this.setState({ toggled: !this.state.toggled }); } render() { return ( <TextInput blurOnSubmit={this.props.blurOnSubmit} multiline={this.props.multiline} onSubmitEditing={this.toggle} style={[styles.textInput, {backgroundColor: this.state.toggled ? 'blue' : 'azure'}]} underlineColorAndroid='transparent' /> ) } } export default class App extends Component<{}> { render() { return ( <View> <ToggleColorInput blurOnSubmit={true} multiline={true} /> <ToggleColorInput blurOnSubmit={true} multiline={false} /> <ToggleColorInput blurOnSubmit={false} multiline={true} /> <ToggleColorInput blurOnSubmit={false} multiline={false} /> </View> ); } } const styles = StyleSheet.create({ textInput: { height: 75, borderWidth: 1, borderColor: 'black' } }); ``` 2. You see four TextInputs, with each combination of the `blurOnSubmit` and `multiline` properties. For each TextInput, type some text and tap the submit button. 3. The TextInputs in this test will toggle background color when they emit an `onSubmitEditing` event. Verify the following behavior on each platform: * blurOnSubmit && isMultiline => Submit event emitted, blurred, no newline inserted * blurOnSubmit && !isMultiline => Submit event emitted, blurred * !blurOnSubmit && isMultiline => Submit event emitted, newline inserted * !blurOnSubmit && !isMultiline => Submit event emitted Closes facebook#16040 Differential Revision: D5877401 Pulled By: shergin fbshipit-source-id: 741bcc06d8b69d7025f2cb42dd0bee4fa01cd88e (cherry picked from commit 4d54b48)
- Loading branch information