Description
Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)
15.2.0 RC
Bug summary
When trying to save content, I get the following exception (was fine on 15.1):
System.NullReferenceException: The property BlockEditorValues must be initialized at value editor construction
at Umbraco.Cms.Core.PropertyEditors.BlockValuePropertyValueEditorBase`2.get_BlockEditorValues()
at Umbraco.Cms.Core.PropertyEditors.BlockValuePropertyValueEditorBase`2.MergeVariantInvariantPropertyValue(Object sourceValue, Object targetValue, Boolean canUpdateInvariantData, HashSet`1 allowedCultures)
at Umbraco.Cms.Core.PropertyEditors.RichTextPropertyEditor.MergeVariantInvariantPropertyValue(Object sourceValue, Object targetValue, Boolean canUpdateInvariantData, HashSet`1 allowedCultures)
at Umbraco.Cms.Core.PropertyEditors.BlockValuePropertyValueEditorBase`2.CleanupVariantValues(List`1 sourceBlockItems, List`1 targetBlockItems, Boolean canUpdateInvariantData, HashSet`1 allowedCultures)
at Umbraco.Cms.Core.PropertyEditors.BlockValuePropertyValueEditorBase`2.MergeVariantInvariantPropertyValue(Object sourceValue, Object targetValue, Boolean canUpdateInvariantData, HashSet`1 allowedCultures)
at Umbraco.Cms.Core.PropertyEditors.BlockListPropertyEditor.MergeVariantInvariantPropertyValue(Object sourceValue, Object targetValue, Boolean canUpdateInvariantData, HashSet`1 allowedCultures)
at Umbraco.Cms.Core.Services.ContentEditingService.EnsureOnlyAllowedFieldsAreUpdated(IContent contentWithPotentialUnallowedChanges, Guid userKey)
at Umbraco.Cms.Core.Services.ContentEditingService.UpdateAsync(Guid key, ContentUpdateModel updateModel, Guid userKey)
at Umbraco.Cms.Api.Management.Controllers.Document.UpdateDocumentController.<>c__DisplayClass4_0.<<Update>b__0>d.MoveNext()
This seems to be happening because the RichTextPropertyValueEditor
constructor is not initializing the BlockValues property here:
Adding this line fixes this issue:
BlockEditorValues = new BlockEditorValues<RichTextBlockValue, RichTextBlockLayoutItem>(new RichTextEditorBlockDataConverter(jsonSerializer), elementTypeCache, logger);
However, this now exposes further issues. The logic for meging blocks seems to be broken, selecting the first element with just a matching culture:
In my testing, this always just selects the first block, which surely cannot be right. I tried selecting with the alias as well:
BlockPropertyValue? sourceBlockPropertyValue =
sourceBlockItem?.Values.FirstOrDefault(v => v.Alias == targetBlockPropertyValue.Alias && v.Culture == targetBlockPropertyValue.Culture);
In my limited testing, this seems to select the right block, though I am unsure if this is always correct
This fix is still not enough, as now the RTE breaks trying to read the blocks JSON. I haven't dug too much into this, but the cause seems to be that it is trying to read the whole JSON value (including the markup
property, instead of only reading the blocks
property.
In short, v15.2 seems to be pretty badly broken when it comes to the block list editor, particularly involving the RTE. You cannot save any content at all.
Specifics
No response
Steps to reproduce
Create a doc type (language variant) with a block grid/list editor that is invariant. Make sure it has an item with an RTE. Watch things break.
If the property has language variants turned on, nothing happens. So this seems to be related to the new blocks variants feature in v15.
Expected result / actual result
I would expect saving content to work normally, no matter what the configuration is