Skip to content

Commit ebd5fb4

Browse files
authored
Fixes save of empty, invariant block list on variant content. (#18932)
1 parent 5f3ce28 commit ebd5fb4

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Umbraco.Infrastructure/PropertyEditors/BlockValuePropertyValueEditorBase.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ private void MapBlockItemDataFromEditor(List<BlockItemData> items)
296296

297297
TValue? mergedBlockValue =
298298
MergeVariantInvariantPropertyValueTyped(source, target, canUpdateInvariantData, allowedCultures);
299+
if (mergedBlockValue is null)
300+
{
301+
return null;
302+
}
299303

300304
return _jsonSerializer.Serialize(mergedBlockValue);
301305
}

tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/BlockListEditorPropertyValueEditorTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ public void Validates_Number_Of_Items_Is_Less_Than_Or_Equal_To_Configured_Max(in
7575
}
7676
}
7777

78+
[Test]
79+
public void MergeVariantInvariantPropertyValue_Can_Merge_Null_Values()
80+
{
81+
var editor = CreateValueEditor();
82+
var result = editor.MergeVariantInvariantPropertyValue(null, null, true, ["en-US"]);
83+
Assert.IsNull(result);
84+
}
85+
7886
private static JsonObject CreateBlocksJson(int numberOfBlocks)
7987
{
8088
var layoutItems = new JsonArray();

0 commit comments

Comments
 (0)