Skip to content

Commit

Permalink
Rich Text: Remove componentDidUpdate deep equality
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Jul 23, 2018
1 parent b4f3327 commit 084328e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
8 changes: 1 addition & 7 deletions editor/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -686,13 +686,7 @@ export class RichText extends Component {
!! this.editor &&
this.props.tagName === prevProps.tagName &&
this.props.value !== prevProps.value &&
this.props.value !== this.savedContent &&

// Comparing using isEqual is necessary especially to avoid unnecessary updateContent calls
// This fixes issues in multi richText blocks like quotes when moving the focus between
// the different editables.
! isEqual( this.props.value, prevProps.value ) &&
! isEqual( this.props.value, this.savedContent )
this.props.value !== this.savedContent
) {
this.setContent( this.props.value );
}
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/specs/__snapshots__/adding-blocks.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`adding blocks Should insert content using the placeholder and the regul
<!-- /wp:paragraph -->
<!-- wp:quote -->
<blockquote class=\\"wp-block-quote\\"><p>Quote block</p></blockquote>
<blockquote class=\\"wp-block-quote\\"><p>Quote block</p><cite>Quote citation</cite></blockquote>
<!-- /wp:quote -->
<!-- wp:image -->
Expand All @@ -24,7 +24,7 @@ exports[`adding blocks Should insert content using the placeholder and the regul
<!-- /wp:paragraph -->
<!-- wp:quote -->
<blockquote class=\\"wp-block-quote\\"><p>Quote block</p></blockquote>
<blockquote class=\\"wp-block-quote\\"><p>Quote block</p><cite>Quote citation</cite></blockquote>
<!-- /wp:quote -->"
`;
Expand All @@ -38,7 +38,7 @@ exports[`adding blocks Should insert content using the placeholder and the regul
<!-- /wp:paragraph -->
<!-- wp:quote -->
<blockquote class=\\"wp-block-quote\\"><p>Quote block</p></blockquote>
<blockquote class=\\"wp-block-quote\\"><p>Quote block</p><cite>Quote citation</cite></blockquote>
<!-- /wp:quote -->
<!-- wp:preformatted -->
Expand Down
8 changes: 2 additions & 6 deletions test/e2e/specs/adding-blocks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ describe( 'adding blocks', () => {
await page.keyboard.type( '/quote' );
await page.keyboard.press( 'Enter' );
await page.keyboard.type( 'Quote block' );
await page.keyboard.press( 'ArrowDown' );
await page.keyboard.type( 'Quote citation' );

// Arrow down into default appender.
await page.keyboard.press( 'ArrowDown' );
await page.keyboard.press( 'ArrowDown' );

// Focus should be moved to block focus boundary on a block which does
// not have its own inputs (e.g. image). Proceeding to press enter will
Expand Down Expand Up @@ -88,11 +89,6 @@ describe( 'adding blocks', () => {
await page.click( '[data-type="core/quote"] .editor-block-list__insertion-point-button' );
await page.keyboard.type( 'Second paragraph' );

// Switch to Text Mode to check HTML Output
await page.click( '.edit-post-more-menu [aria-label="More"]' );
const codeEditorButton = ( await page.$x( '//button[contains(text(), \'Code Editor\')]' ) )[ 0 ];
await codeEditorButton.click( 'button' );

expect( await getEditedPostContent() ).toMatchSnapshot();
} );
} );

0 comments on commit 084328e

Please sign in to comment.