Skip to content

Commit

Permalink
Force Aztec update if "Enter" fired before text change
Browse files Browse the repository at this point in the history
  • Loading branch information
hypest committed Apr 25, 2019
1 parent 724e295 commit 46e086d
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 ) {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -701,6 +702,7 @@ export class RichText extends Component {

if ( this.comesFromAztec ) {
this.comesFromAztec = false;
this.firedAfterTextChanged = false;
}

return (
Expand Down

0 comments on commit 46e086d

Please sign in to comment.