rickbutterfield / Umbraco.Community.BlockPreview

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

Two Column Layout error "Something went wrong rendering a preview" #12

Closed 37Stars closed 1 year ago

37Stars commented 1 year ago

I created a new empty project to try the BlockPreview. These are my steps:

  1. Created a new Umbraco 10.4 solution. (Also get the same error with 11.2).
  2. Added BlockPreview 1.1.1 via nuget
  3. Created a new Data Type named Content Block Grid.
  4. Within Content Block Grid, click button to create Demo Blocks. That added 4 new Document Types.
  5. Created a new Document Type named Web Page with a single data type, Content Block Grid, named Page Content. Set allow as Root.
  6. Created a new Web Page named Home and added the Two Column Layout to the Page Content.
  7. Updated the umbBlockGridDemoTwoColumnLayoutBlock.cshtml view (located in \Views\Partials\blockgrid\Components) from Html.GetBlockGridItemAreasHtmlAsync(Model) to Html.GetPreviewBlockGridItemAreasHtmlAsync(Model). Both produce the same error.

When editing the Home page in the back office the Two Column Layout displays the message "Something went wrong rendering a preview".

The blocks Headline, Image and Rich Text display without any issues. Am I missing something?

rickbutterfield commented 1 year ago

Hi @37Stars!

Firstly, thank you for such great replication steps! This has made it really easy to trace down the bug.

Secondly, are you using ModelsBuilder at all in your solution? I've presumed not because you're creating a new solution out of the box. If it's the case that you're not, I think I've got a fix!

37Stars commented 1 year ago

I can do either, but would prefer to use ModelsBuilder.

rickbutterfield commented 1 year ago

Excellent, I think I've got a fix then! I've only managed to replicate your issue when ModelBuilder was set to InMemoryAuto, or one of the SourceCode modes but not generated yet, but this fixes one of the first issues I found with the code!

rickbutterfield commented 1 year ago

@37Stars please test version 1.1.2 whenever you get chance! https://www.nuget.org/packages/Umbraco.Community.BlockPreview/1.1.2#readme-body-tab

37Stars commented 1 year ago

@rickbutterfield yes, that works great!

The only issue remaining is an Umbraco issue. When I add content to one of those two columns, Umbraco displays the properties panel for the two-column layout over the "Add Content" panel. Clicking "Discard Changes" takes care of that.