Skip to content

Commit

Permalink
Differentiate Android and iOS since assumptions diverged
Browse files Browse the repository at this point in the history
The iOS side still expects to just check against `this.lastContent` to
force the change into Aztec.
  • Loading branch information
hypest committed Apr 25, 2019
1 parent 52386fa commit 724e295
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions packages/block-editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 724e295

Please sign in to comment.