From 724e2951d7410d851556477796c8b9e624ee2f15 Mon Sep 17 00:00:00 2001 From: Stefanos Togkoulidis Date: Thu, 25 Apr 2019 03:11:52 +0300 Subject: [PATCH] Differentiate Android and iOS since assumptions diverged The iOS side still expects to just check against `this.lastContent` to force the change into Aztec. --- .../src/components/rich-text/index.native.js | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 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 c05a9afa5e29f8..0ba394d296ed77 100644 --- a/packages/block-editor/src/components/rich-text/index.native.js +++ b/packages/block-editor/src/components/rich-text/index.native.js @@ -606,17 +606,20 @@ export class RichText extends Component { // If the component is changed React side (undo/redo/merging/splitting/custom text actions) // we need to make sure the native is updated as well. - if ( this.comesFromAztec === false ) { - // Also, don't trust the "this.lastContent" as on Android, incomplete text events arrive - // with only some of the text, while the virtual keyboard's suggestion system does its magic. - // ** compare with this.lastContent for optimizing performance by not forcing Aztec with text it already has - // , 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' ) && - nextProps.value !== this.props.value ) { - this.lastEventCount = undefined; // force a refresh on the native side - } + const previousValueToCheck = Platform.OS === 'android' ? this.props.value : this.lastContent; + + // Also, don't trust the "this.lastContent" as on Android, incomplete text events arrive + // with only some of the text, while the virtual keyboard's suggestion system does its magic. + // ** compare with this.lastContent for optimizing performance by not forcing Aztec with text it already has + // , 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 ) ) && + nextProps.value !== previousValueToCheck ) { + this.lastEventCount = undefined; // force a refresh on the native side + } + if ( Platform.OS == 'android' && this.comesFromAztec === false ) { if ( this.needsSelectionUpdate ) { this.lastEventCount = undefined; // force a refresh on the native side }