Skip to content

Nested Block List previews: DropDown.Flexible values lost due to double FormatBlockData processing #280

@arenisland

Description

@arenisland

Which Umbraco.Community.BlockPreview version are you using?

5.3.2

Which Umbraco version are you using? For example: 10.4.0 - don't just write v10

17.2.2

Bug summary

Notice, since english isn't my first language I used an AI to describe the issue. Hopefully without any AI slop.

When using Block List previews with nested blocks (e.g., a layout block containing a Block List of items that themselves have Umbraco.DropDown.Flexible properties), the dropdown values are empty in the preview.

Root cause:

FormatBlockData is called multiple times on the same nested block data. The first pass correctly converts dropdown values via FromEditor (List → string "["purple"]"). However, due to JsonObjectConverter in the serialization options, the string ["purple"] is written as a raw JSON array during serialization. When the data is deserialized for the second pass, the value is back as a string "["purple"]" (already in DB format).
FromEditor does not expect a string input for DropDown.Flexible — it expects List (editor format) — and returns null, wiping the value.

This only manifests with nested Block Lists. When previewing the block directly (single level), the values render correctly because the data only goes through one effective FormatBlockData cycle.

Evidence from logs:

BEFORE: Umbraco.DropDown.Flexible(size)=String:["standard"] ← already a string (DB format)
ConvertPropertyValue IN: Type=System.String, Value=["standard"]
ConvertPropertyValue OUT: Type=null, Value=null ← FromEditor returns null for string input AFTER: Umbraco.DropDown.Flexible(size)=: ← value lost
Our workaround in a custom IBlockDataConverter: Skip FromEditor for DropDown.Flexible when the value is already a string, since that means it has already been converted in a previous pass:

  if (propertyData.EditorAlias == PropertyEditors.Aliases.DropDownListFlexible                                                                                                                                             
      && propertyData.Value is string)                                                                                                                                                                                           return;

This is similar in spirit to the nested Block Grid fix in #173 / ad54c21, but for Block List nesting. The underlying issue is that ConvertPropertyValue/FromEditor is not idempotent for editors where FromEditor changes the value type — calling it twice on the same data destroys the value on the second pass.
Other editors that convert List to a JSON string (e.g., CheckboxList) may have the same issue.

Steps to reproduce

  1. Create a Block List configuration with at least two levels of nesting, e.g.:
    - A "Layout" block type containing a Block List property
    - Inside that Block List, a "Card" block type with Umbraco.DropDown.Flexible properties (e.g., "Size" with values like "standard", "large")
  2. Create a page, add the Layout block, and inside it add Card items with dropdown values selected
  3. Observe the preview rendered for the Layout block in the backoffice

Expected result / actual result

Expected result:
The nested Card blocks render with their dropdown values applied (e.g., correct CSS classes based on the selected size/color).

Actual result:

The dropdown values are empty. The IPublishedElement properties return empty strings for all DropDown.Flexible fields on nested blocks. Previewing the Card block directly (clicking into the Block List) renders correctly — the issue only occurs when the preview is triggered from the parent Layout block level.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions