From 46e086d58f7b4531e66e75e41050f1e5da496ef8 Mon Sep 17 00:00:00 2001 From: Stefanos Togkoulidis Date: Thu, 25 Apr 2019 03:59:59 +0300 Subject: [PATCH] Force Aztec update if "Enter" fired before text change --- .../block-editor/src/components/rich-text/index.native.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/rich-text/index.native.js b/packages/block-editor/src/components/rich-text/index.native.js index 0ba394d296ed77..1a337b55106956 100644 --- a/packages/block-editor/src/components/rich-text/index.native.js +++ b/packages/block-editor/src/components/rich-text/index.native.js @@ -291,6 +291,7 @@ export class RichText extends Component { onEnter( event ) { this.lastEventCount = event.nativeEvent.eventCount; this.comesFromAztec = true; + this.firedAfterTextChanged = event.nativeEvent.firedAfterTextChanged; const currentRecord = this.createRecord( { ...event.nativeEvent, @@ -309,7 +310,7 @@ export class RichText extends Component { } else { // if ( ! event.nativeEvent.firedAfterTextChanged ) { const insertedLineSeparator = { needsSelectionUpdate: true, ...insertLineSeparator( currentRecord ) }; - this.onFormatChange( insertedLineSeparator, ! event.nativeEvent.firedAfterTextChanged ); + this.onFormatChange( insertedLineSeparator, ! this.firedAfterTextChanged ); // } } } else if ( event.shiftKey || ! this.onSplit ) { @@ -614,7 +615,7 @@ export class RichText extends Component { // , but compare with props.value to not lose "half word" text because of Android virtual keyb autosuggestion behavior if ( ( typeof nextProps.value !== 'undefined' ) && ( typeof this.props.value !== 'undefined' ) && - ( Platform.OS === 'ios' || ( Platform.OS == 'android' && this.comesFromAztec === false ) ) && + ( Platform.OS === 'ios' || ( Platform.OS == 'android' && ( ! this.comesFromAztec || ! this.firedAfterTextChanged ) ) ) && nextProps.value !== previousValueToCheck ) { this.lastEventCount = undefined; // force a refresh on the native side } @@ -701,6 +702,7 @@ export class RichText extends Component { if ( this.comesFromAztec ) { this.comesFromAztec = false; + this.firedAfterTextChanged = false; } return (