diff --git a/packages/rich-text/src/component/index.native.js b/packages/rich-text/src/component/index.native.js index 4176b0d20fc3a..c268951a091a8 100644 --- a/packages/rich-text/src/component/index.native.js +++ b/packages/rich-text/src/component/index.native.js @@ -411,6 +411,11 @@ export class RichText extends Component { onBlur( event ) { this.isTouched = false; + // Check if value is up to date with latest state of native AztecView + if ( event.nativeEvent.text && event.nativeEvent.text !== this.props.value ) { + this.onTextUpdate( event ); + } + if ( this.props.onBlur ) { this.props.onBlur( event ); } @@ -457,8 +462,16 @@ export class RichText extends Component { // Make sure there are changes made to the content before upgrading it upward this.onTextUpdate( event ); - this.onSelectionChange( realStart, realEnd ); - + // Aztec can send us selection change events after it has lost focus. + // For instance the autocorrect feature will complete a partially written + // word when resigning focus, causing a selection change event. + // Forwarding this selection change could cause this RichText to regain + // focus and start a focus loop. + // + // See https://github.com/wordpress-mobile/gutenberg-mobile/issues/1696 + if ( this.props.__unstableIsSelected ) { + this.onSelectionChange( realStart, realEnd ); + } // Update lastEventCount to prevent Aztec from re-rendering the content it just sent this.lastEventCount = event.nativeEvent.eventCount;