rickbutterfield / Umbraco.Community.BlockPreview

Easy to use rich HTML backoffice previews for the Umbraco Block List and Block Grid editors.
MIT License
15 stars 10 forks source link

Nesting a Block Grid in a Block List doesn't render the grid properly #30

Closed robertjf closed 11 months ago

robertjf commented 11 months ago

We have a set up that allows us to render a Block Grid in a Block List component, which is designed (currently) to allow us to render a two-column section in the list.

The problem is that the content in the Block Grid doesn't render at all in this situation, because the actual content is being substituted out for string in the AREA_TEMPLATE constant when in fact it needs to be rendered correctly in this instance.

I've resolved this by adding another ViewData entry called "blockGridPreview" in BackOfficeGridPreviewService and checking for that in the GetPreviewBlockGridItemAreasHtmlAsync extension method and friends. This will only be set if the Grid is the primary property type.

This will still not work if we have a Grid Block nested in a Grid Block for some reason (and why would you want to anyway).

A better solution may be to somehow scope the substitution that these extension methods do to the current "nesting level" and ensure it's only done if at the root of the tree.

There's a PR coming to resolve this.

rickbutterfield commented 11 months ago

Now released in v1.7.1, #h5yr @robertjf!