Skip to content

Commit

Permalink
Fixed loss of list content when switching list types. (#32432)
Browse files Browse the repository at this point in the history
* add `value` to dependencies

* Add the variables used in setRecordFromProps to dependencies.

* use _value.current  instead of value

* revert change

* add tagName to __unstableDependencies

* add e2e test.

* format

* fix snapshot
  • Loading branch information
torounit authored and youknowriad committed Jun 7, 2021
1 parent 61ce1f4 commit 476b88f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function RichTextWrapper(
__unstableMultilineTag: multilineTag,
__unstableDisableFormats: disableFormats,
preserveWhiteSpace,
__unstableDependencies: dependencies,
__unstableDependencies: [ ...dependencies, tagName ],
__unstableAfterParse: addEditorOnlyFormats,
__unstableBeforeSerialize: removeEditorOnlyFormats,
__unstableAddInvisibleFormats: addInvisibleFormats,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ exports[`List should insert a line break on shift+enter in a non trailing list i
<!-- /wp:list -->"
`;
exports[`List should not change the contents when you change the list type to Unordered 1`] = `"<li>a</li><li>b</li><li>c</li>"`;
exports[`List should not change the contents when you change the list type to Ordered 1`] = `"<li>1</li><li>2</li><li>3</li>"`;
exports[`List should not indent list on space with modifier 1`] = `
"<!-- wp:list -->
<ul><li>1</li><li> </li></ul>
Expand Down
32 changes: 32 additions & 0 deletions packages/e2e-tests/specs/editor/blocks/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,4 +507,36 @@ describe( 'List', () => {

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

it( 'should not change the contents when you change the list type to Ordered', async () => {
await clickBlockAppender();
await page.keyboard.type( '* 1' );
await page.keyboard.press( 'Enter' );
await page.keyboard.type( '2' );
await page.keyboard.press( 'Enter' );
await page.keyboard.type( '3' );
await clickBlockToolbarButton( 'Ordered' );

const content = await page.$eval(
'.wp-block-list',
( el ) => el.innerHTML
);
expect( content ).toMatchSnapshot();
} );

it( 'should not change the contents when you change the list type to Unordered', async () => {
await clickBlockAppender();
await page.keyboard.type( '1. a' );
await page.keyboard.press( 'Enter' );
await page.keyboard.type( 'b' );
await page.keyboard.press( 'Enter' );
await page.keyboard.type( 'c' );
await clickBlockToolbarButton( 'Unordered' );

const content = await page.$eval(
'.wp-block-list',
( el ) => el.innerHTML
);
expect( content ).toMatchSnapshot();
} );
} );

0 comments on commit 476b88f

Please sign in to comment.