-
Notifications
You must be signed in to change notification settings - Fork 23
Description
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
- Create a new article
- In the article, create a new line with several characters. Select the characters and format them as heading.
- Delete the characters but keep the empty line
- Click "Update"
- Navigate back to the article listing page. The page should be blank
- 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.
The above line maps to this function in the source code:
dispatch/dispatch/static/manager/src/js/vendor/dispatch-editor/helpers/convertJSON.js
Lines 118 to 126 in 6612ebe
| 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:
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"}}
