rickbutterfield / Umbraco.Community.BlockPreview

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

Nested elements are not rendered when using preview helpers. #37

Closed bielu closed 3 months ago

bielu commented 11 months ago

I spend some time debugging our solution to notice this bit of docs is kinda incorrect: https://github.com/rickbutterfield/Umbraco.Community.BlockPreview#grid-specific-setup If you replace all block rendering methods with preview ones, you will have no render of nested elements.

So I played around and noticed, this when I set:

is only case when i get all preview render correctly.

So based on my observation, it doesnt work if you use Preview Methods everywhere, but it works perfectly when you use the Preview method on Root view for current preview.

timeverts commented 7 months ago

I spend some time debugging our solution to notice this bit of docs is kinda incorrect: https://github.com/rickbutterfield/Umbraco.Community.BlockPreview#grid-specific-setup If you replace all block rendering methods with preview ones, you will have no render of nested elements.

So I played around and noticed, this when I set:

  • Default grid view to use GetPreviewBlockGridItemsHtmlAsync
  • area view to use GetBlockGridItemsHtmlAsync
  • areas view to use GetBlockGridItemAreaHtmlAsync

is only case when i get all preview render correctly.

So based on my observation, it doesnt work if you use Preview Methods everywhere, but it works perfectly when you use the Preview method on Root view for current preview.

@bielu, I also found your described setup to be necessary to allow preview of nested block grid/list editors to be supported across the CMS.

@rickbutterfield, perhaps the documentation needs an update?

rickbutterfield commented 7 months ago

Hey @bielu and @timeverts, thanks so much for raising the issue. This appears to be the same issue as #47 and a fix is incoming in v1.8.1, releasing later today or early tomorrow.

In every test I've done when working on it, I've tried using both the GetBlockGrid... and GetPreviewBlockGrid... methods, and it only appears to work for me correctly when using the Preview versions, so it would be good to get your feedback post-release.

bielu commented 7 months ago

@rickbutterfield it is not same issue, as this issue was related to umbraco 10, #47 is related to this : https://github.com/umbraco/Umbraco-CMS/pull/15799 which was breaking change in umbraco v13. but fix might actually fix both, so will test it :)

rickbutterfield commented 7 months ago

Your changes for https://github.com/umbraco/Umbraco-CMS/pull/15799 are exactly where I found the issue in BlockPreview! I've now added code that handles that case and converts nested lists and grids to from JSON to string, so that the conversion can happen.

rickbutterfield commented 7 months ago

v1.8.1 is released now, if you are able to test and confirm if it's working?

bielu commented 7 months ago

Yeah, it actually caused more issues for me, will try find issue for it and submit pr :)

bielu commented 6 months ago

Hmm interesting 1.8.2 with umbraco 13.2.2 seems to solve issue 🤔, not sure how but it works! 😂 However it still require me mixing of GetPreviewBlockGridItemsHtmlAsync and GetBlockGridItemsHtmlAsync