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

Manager cannot load article with empty heading #988

Open
psiemens opened this issue Nov 2, 2020 · 1 comment
Open

Manager cannot load article with empty heading #988

psiemens opened this issue Nov 2, 2020 · 1 comment

Comments

@psiemens
Copy link
Member

psiemens commented Nov 2, 2020

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"}}
@psiemens
Copy link
Member Author

psiemens commented Nov 2, 2020

This crashed the manager in production for the ubyssey.ca deployment of Dispatch. After an article was saved with an empty heading, the article listing page crashed for any listing that included the "bad" article.

To immediately fix the problem, I manually updated the bad article to remove the empty heading block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant