Skip to content

Support setting correct values for nested blocklists#285

Closed
timoschraa wants to merge 3 commits intorickbutterfield:v5/devfrom
timoschraa:v5/bugfix/nested-blocklists
Closed

Support setting correct values for nested blocklists#285
timoschraa wants to merge 3 commits intorickbutterfield:v5/devfrom
timoschraa:v5/bugfix/nested-blocklists

Conversation

@timoschraa
Copy link
Copy Markdown

By removing the FormatBlockData when editorAlias = BlockList/BlockGrid it looks like the preview is working for nested blocklists. Also did some refactoring because _blockGridEditorValues.DeserializeAndClean already does a .ToString().

I couldn't test the BlockGrid because we don't use it in our solutions.

Fix for #284.

Timo Schraa added 3 commits March 30, 2026 16:54
….DeserializeAndClean also executes .ToString()
…rs.Aliases.BlockList because it looks like Umbraco handles it
…rs.Aliases.BlockGrid because it looks like Umbraco handles it (not tested in solution because we don't use a BlockGrid)
@timoschraa timoschraa changed the title V5/bugfix/nested blocklists Support setting correct values for nested blocklists Mar 30, 2026
@rickbutterfield
Copy link
Copy Markdown
Owner

rickbutterfield commented Apr 11, 2026

Hey @timoschraa! Thanks for looking into this and the detail on #284 - it's been really useful for me to get to the bottom of the issue.

I've traced the root cause and it's not the recursion in FormatBlockData itself, it's that FormatBlockData was being called twice on the same nested block data:

  1. BlockPreviewService called FormatBlockData(blockValue.BlockValue.ContentData) on all content data, which recursively processed nested blocks and called FromEditor on their non-block properties
  2. Then ConvertToElement was called for the target block, which called FormatBlockData again on the nested blocks inside that block's block editor properties

So for a nested MNTP: the first call converted JsonArrayString, and the second call got String and FromEditor returned null.

I've fixed this in 4f0dd01 by:

  • Removing the FormatBlockData calls from BlockPreviewService (all 3 render methods)
  • Adding an else clause in ConvertToElement so it handles non-block property conversion directly via ConvertPropertyValue

This way ConvertToElement is the single entry point. It converts non-block properties on the target block and calls FormatBlockData for nested blocks, with recursion handling all depths. Each property is processed exactly once.

I've also added tests covering nested BlockList/BlockGrid at two and three levels deep, nesting of List and Grid combined, and a regression test specifically for the double conversion you've raised.

Going to close this PR since the fix is now on v5/dev, but thank you for the investigation. The log output in #284 was really helpful for pinpointing the issue! #h5yr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants