Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RichText: fix br padding in multiline and nesting #14315

Merged
merged 2 commits into from
Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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