Skip to content

Commit

Permalink
RichText: fix br padding in multiline and nesting (#14315)
Browse files Browse the repository at this point in the history
* RichText: fix br padding in multiline and nesting

* Add e2e test
  • Loading branch information
ellatrix authored and youknowriad committed Mar 20, 2019
1 parent da5f572 commit bb8c6ff
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ exports[`adding blocks should navigate around nested inline boundaries 2`] = `
<!-- /wp:paragraph -->"
`;
exports[`adding blocks should not create extra line breaks in multiline value 1`] = `
"<!-- wp:quote -->
<blockquote class=\\"wp-block-quote\\"><p></p></blockquote>
<!-- /wp:quote -->"
`;
exports[`adding blocks should not delete surrounding space when deleting a selected word 1`] = `
"<!-- wp:paragraph -->
<p>alpha gamma</p>
Expand Down
8 changes: 8 additions & 0 deletions packages/e2e-tests/specs/writing-flow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
createNewPost,
pressKeyTimes,
pressKeyWithModifier,
insertBlock,
} from '@wordpress/e2e-test-utils';

describe( 'adding blocks', () => {
Expand Down Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions packages/rich-text/src/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ function createFromElement( {
multilineTag,
multilineWrapperTags,
currentWrapperTags: [ ...currentWrapperTags, format ],
isEditableTree,
} );
format = undefined;
} else {
Expand All @@ -345,6 +346,7 @@ function createFromElement( {
range,
multilineTag,
multilineWrapperTags,
isEditableTree,
} );
}

Expand Down Expand Up @@ -423,6 +425,7 @@ function createFromMultilineElement( {
multilineTag,
multilineWrapperTags,
currentWrapperTags = [],
isEditableTree,
} ) {
const accumulator = createEmptyValue();

Expand All @@ -446,6 +449,7 @@ function createFromMultilineElement( {
multilineTag,
multilineWrapperTags,
currentWrapperTags,
isEditableTree,
} );

// Multiline value text should be separated by a double line break.
Expand Down

0 comments on commit bb8c6ff

Please sign in to comment.