Skip to content
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
2 changes: 1 addition & 1 deletion packages/block-library/src/list/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function createListBlockFromDOMElement( listElement ) {
const [ nestedList, ...nodes ] = children;

const hasNestedList =
nestedList.tagName === 'UL' || nestedList.tagName === 'OL';
nestedList?.tagName === 'UL' || nestedList?.tagName === 'OL';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange how there's no e2e test catching this. Should we add one to test migration from an empty list? How come the integration deprecation tests are passing?

Copy link
Member Author

@oandregal oandregal Sep 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed one at aae4651 (it fails without this fix).

if ( ! hasNestedList ) {
return createBlock( 'core/list-item', {
content: listItem.innerHTML,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- wp:list -->
<ul><!-- wp:list-item -->
<li></li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->
21 changes: 21 additions & 0 deletions test/e2e/specs/editor/blocks/list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1132,4 +1132,25 @@ test.describe( 'List', () => {
<!-- /wp:list -->`
);
} );

test( 'can be created by pasting an empty list', async ( {
editor,
pageUtils,
} ) => {
// Open code editor
await pageUtils.pressKeyWithModifier( 'secondary', 'M' ); // Emulates CTRL+Shift+Alt + M => toggle code editor

// Paste empty list block
await pageUtils.setClipboardData( {
plainText:
'<!-- wp:list -->\n<ul><li></li></ul>\n<!-- /wp:list -->',
} );
await pageUtils.pressKeyWithModifier( 'primary', 'v' );

// Go back to normal editor
await pageUtils.pressKeyWithModifier( 'secondary', 'M' ); // Emulates CTRL+Shift+Alt + M => toggle code editor

// Verify no WSOD and content is proper.
expect( await editor.getEditedPostContent() ).toMatchSnapshot();
} );
} );