From 47b1f7a2243e58766b7edc04a68bae5e0ef5cb2a Mon Sep 17 00:00:00 2001 From: iseulde Date: Thu, 7 Mar 2019 14:32:40 +0100 Subject: [PATCH 1/2] RichText: fix br padding in multiline and nesting --- packages/rich-text/src/create.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/rich-text/src/create.js b/packages/rich-text/src/create.js index 82348bbd4fa8aa..df44623df28c4a 100644 --- a/packages/rich-text/src/create.js +++ b/packages/rich-text/src/create.js @@ -337,6 +337,7 @@ function createFromElement( { multilineTag, multilineWrapperTags, currentWrapperTags: [ ...currentWrapperTags, format ], + isEditableTree, } ); format = undefined; } else { @@ -345,6 +346,7 @@ function createFromElement( { range, multilineTag, multilineWrapperTags, + isEditableTree, } ); } @@ -423,6 +425,7 @@ function createFromMultilineElement( { multilineTag, multilineWrapperTags, currentWrapperTags = [], + isEditableTree, } ) { const accumulator = createEmptyValue(); @@ -446,6 +449,7 @@ function createFromMultilineElement( { multilineTag, multilineWrapperTags, currentWrapperTags, + isEditableTree, } ); // Multiline value text should be separated by a double line break. From e2d446234732e5c9ed574d7601dac71707528824 Mon Sep 17 00:00:00 2001 From: iseulde Date: Thu, 7 Mar 2019 14:57:32 +0100 Subject: [PATCH 2/2] Add e2e test --- .../specs/__snapshots__/writing-flow.test.js.snap | 6 ++++++ packages/e2e-tests/specs/writing-flow.test.js | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/packages/e2e-tests/specs/__snapshots__/writing-flow.test.js.snap b/packages/e2e-tests/specs/__snapshots__/writing-flow.test.js.snap index dca0ce4763cdbb..41f6fe04a2b531 100644 --- a/packages/e2e-tests/specs/__snapshots__/writing-flow.test.js.snap +++ b/packages/e2e-tests/specs/__snapshots__/writing-flow.test.js.snap @@ -126,6 +126,12 @@ exports[`adding blocks should navigate around nested inline boundaries 2`] = ` " `; +exports[`adding blocks should not create extra line breaks in multiline value 1`] = ` +" +

+" +`; + exports[`adding blocks should not delete surrounding space when deleting a selected word 1`] = ` "

alpha gamma

diff --git a/packages/e2e-tests/specs/writing-flow.test.js b/packages/e2e-tests/specs/writing-flow.test.js index d0b46970c87f4e..62ece158016405 100644 --- a/packages/e2e-tests/specs/writing-flow.test.js +++ b/packages/e2e-tests/specs/writing-flow.test.js @@ -7,6 +7,7 @@ import { createNewPost, pressKeyTimes, pressKeyWithModifier, + insertBlock, } from '@wordpress/e2e-test-utils'; describe( 'adding blocks', () => { @@ -208,6 +209,13 @@ describe( 'adding blocks', () => { expect( await getEditedPostContent() ).toMatchSnapshot(); } ); + it( 'should not create extra line breaks in multiline value', async () => { + await insertBlock( 'Quote' ); + await page.keyboard.type( 'a' ); + await page.keyboard.press( 'Backspace' ); + expect( await getEditedPostContent() ).toMatchSnapshot(); + } ); + it( 'should navigate native inputs vertically, not horizontally', async () => { // See: https://github.com/WordPress/gutenberg/issues/9626