Try our conversational search powered by Generative AI!

Clearing a block in a block list breaks edit UI

Found in

EPiServer.CMS.Core 12.19.1

Fixed in

EPiServer.CMS.Core 12.20.0

Created

Nov 01, 2023

Updated

Jan 31, 2024

Area

CMS Core

State

Closed, Fixed and tested


Description

Fixed an issue that caused the edit UI to break when you cleared a block in a block list.

Prerequisite

Add block types as following to the site (such as the Alloy sample site):
[ContentType]public class AccordionBlock : BlockData

{{{ public virtual string? Title

{ get; set; } public virtual IList<AccordionItemBlock>? Items { get; set; }}}
}
{{[ContentType]public class AccordionItemBlock : BlockData{ public virtual string? Title{ get; set; }

}}

{{public virtual string? Subtitle { get; set; } public virtual XhtmlString? Body{ get; set; }}}
}

Steps to reproduce

  1. Enable inline blocks for the site (UIOptions.InlineBlocksInContentAreaEnabled = true).
  2. Create a new instance of Accordion Block against a page as an inline block.
  3. Add three child items into AccordionBlock.Items with each item having values in every property.
  4. Save the block.
  5. Save and publish the page.
  6. Refresh the page.
  7. Edit the Accordion block.
  8. Expand the second child item.
  9. Remove the text from every property within the second child item.
  10. Save the block, and save and publish the page. At this point you, a null reference exception displays because of the lack of null handling in the aforementioned CMS code.
  11. Refresh the page in the browser. Note that the page does not load in the browser.
  12. Check the network settings and see a 500 error response on the API call to get the page data.