From e1e6b60bb290e5ed2deace98c1c4700d908967a4 Mon Sep 17 00:00:00 2001 From: Danilo Ercoli Date: Tue, 23 Apr 2019 12:37:51 +0200 Subject: [PATCH] [RNMobile] Fix for history stack that's is not empty on a fresh start of the editor (#15055) * Do not reset the content in onSelectionChange * Make sure there are changes made to the content before upgrading it upward * Refactor: Introduce a local variable and DRY the code a bit * Fix lint --- .../src/components/rich-text/index.native.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 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 ffea24cffbf2a5..99a65f60396add 100644 --- a/packages/block-editor/src/components/rich-text/index.native.js +++ b/packages/block-editor/src/components/rich-text/index.native.js @@ -481,10 +481,15 @@ export class RichText extends Component { formatPlaceholder, } ); this.lastEventCount = event.nativeEvent.eventCount; - // we don't want to refresh aztec as no content can have changed from this event - // let's update lastContent to prevent that in shouldComponentUpdate - this.lastContent = this.removeRootTagsProduceByAztec( unescapeSpaces( text ) ); - this.props.onChange( this.lastContent ); + + // Make sure there are changes made to the content before upgrading it upward + const newContent = this.removeRootTagsProduceByAztec( unescapeSpaces( text ) ); + if ( this.lastContent !== newContent ) { + // we don't want to refresh aztec native as no content can have changed from this event + // let's update lastContent to prevent that in shouldComponentUpdate + this.lastContent = newContent; + this.props.onChange( this.lastContent ); + } } isEmpty() {