diff --git a/.travis.yml b/.travis.yml index 122858672c93e..8798f87bb55da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ branches: only: - master - rnmobile/master - - rnmobile/releases + - /rnmobile\/release.*/ - /wp\/.*/ env: diff --git a/packages/block-editor/src/components/plain-text/index.native.js b/packages/block-editor/src/components/plain-text/index.native.js index 8790e593e8942..9ddb1fba7465c 100644 --- a/packages/block-editor/src/components/plain-text/index.native.js +++ b/packages/block-editor/src/components/plain-text/index.native.js @@ -16,22 +16,39 @@ import styles from './style.scss'; export default class PlainText extends Component { constructor() { super( ...arguments ); - this.isIOS = Platform.OS === 'ios'; + this.isAndroid = Platform.OS === 'android'; } componentDidMount() { // if isSelected is true, we should request the focus on this TextInput if ( this._input.isFocused() === false && this.props.isSelected ) { - this.focus(); + if ( this.isAndroid ) { + /* + * There seems to be an issue in React Native where the keyboard doesn't show if called shortly after rendering. + * As a common work around this delay is used. + * https://github.com/facebook/react-native/issues/19366#issuecomment-400603928 + */ + this.timeoutID = setTimeout( () => { + this._input.focus(); + }, 100 ); + } else { + this._input.focus(); + } } } componentDidUpdate( prevProps ) { - if ( ! this.props.isSelected && prevProps.isSelected && this.isIOS ) { + if ( ! this.props.isSelected && prevProps.isSelected ) { this._input.blur(); } } + componentWillUnmount() { + if ( this.isAndroid ) { + clearTimeout( this.timeoutID ); + } + } + focus() { this._input.focus(); }