Skip to content

Property value(s) aren't always set correctly #284

@timoschraa

Description

@timoschraa

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

In our projects we work with nested blocklists. This means you first create rows and for every row you can set 1 or more columns and on those columns you can place components.

When the BlockPreview is added, some properties of the components will not correctly be set when viewing the preview on the rows. When one of the rows is opened, all properties are set correctly.

This occurs because in the ConvertToElement, the FormatBlockData is called because the content of the row is a Blocklist. In the FormatBlockData the ConvertToPropertyValue is executed for, amongst others, the propertytype MultiNodeTreePicker. On line 231 in the BlockDataConverter the statement propertyData.Value = valueEditor.FromEditor(editorValue, null); is executed but in the MultiNodeTreePickerPropertyValueEditor the method FromEditor is defined like:

public override object? FromEditor(ContentPropertyData editorValue, object? currentValue)
            => editorValue.Value is JsonArray jsonArray
                ? EntityReferencesToUdis(_jsonSerializer.Deserialize<IEnumerable<EditorEntityReference>>(jsonArray.ToJsonString()) ?? Enumerable.Empty<EditorEntityReference>())
                : null;

But in an earlier stage the values of the MultiNodeTreePicker are cleaned to an Udi (e.g. "umb://document/" so the .FromEditor will result in a null value here. They are converted to an Udi because in an earlier stage they are converted with the above mentioned MultiNodeTreePickerPropertyValueEditor.FromEditor. This results in a log debug.

In the logs you can find multiple lines like:

BlockPreview: FromEditor converted '"Umbraco.MultiNodeTreePicker"' from "JsonArray" to "String"

and afterwards

BlockPreview: FromEditor returned null for property '"Umbraco.MultiNodeTreePicker"' (was "String"). Original value: "umb://document/02a05ae198d44776905584034d1f6ade"

When you open the row, the content isn't a blocklist so it won't hit the functionalities like when on the overview. Therefore it works when you opened the row.

As you can see below, on the overview there is no slider but when the row is opened there is.

20260329-1613-24.0458695.mp4

Steps to reproduce

Create a blocklist for your content with elements (rows) and make the content on the rows also a blocklist. On these elements, add a Content Picker (MultiNodeTreePicker) and set a value. It won't work in the overview preview but will work when you open the row.

Expected result / actual result

No response

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