Skip to content

Manager cannot load article with empty heading #988

@psiemens

Description

@psiemens

What behaviour were you expecting?

The Dispatch admin panel should not fail to load articles with empty headings.

What actually happened?

The Dispatch admin panel crashes when loading an article with an empty heading.

This error occurs primarily on the article listing page, given that the listing includes an article with an empty heading.

Steps to reproduce

  1. Create a new article
  2. In the article, create a new line with several characters. Select the characters and format them as heading.
  3. Delete the characters but keep the empty line
  4. Click "Update"
  5. Navigate back to the article listing page. The page should be blank
  6. Observe the error in the JS console

What was your environment like?

Google Chrome Version 86.0.4240.111, macOS

Do you have any logs?

The error occurs on this un-minified line.

Screen Shot 2020-10-25 at 12 48 01 AM

The above line maps to this function in the source code:

function headerToBlock(block) {
const contentBlocks = convertFromHTML(block.data.content).contentBlocks
.map(contentBlock => contentBlock.set('type', DRAFT_TYPES.HEADER))
return {
contentBlocks: contentBlocks,
entityMap: {}
}
}

The Chrome Debugger shows the value of the block parameter:

Screen Shot 2020-10-25 at 12 56 08 AM

block is a single element taken directly from the content field of an article API response. In this case, the original JSON value is:

{"type":"header","data":{"content":"","size":"h2"}}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions