diff --git a/src/Umbraco.Community.BlockPreview/Services/BlockPreviewService.cs b/src/Umbraco.Community.BlockPreview/Services/BlockPreviewService.cs index c0b4c0f..8f834cb 100644 --- a/src/Umbraco.Community.BlockPreview/Services/BlockPreviewService.cs +++ b/src/Umbraco.Community.BlockPreview/Services/BlockPreviewService.cs @@ -108,11 +108,13 @@ public async Task RenderGridBlock( List? layoutItems = blockData?.Layout?.FirstOrDefault().Value.Select(layout => layout.ToString()).ToList(); BlockGridLayoutItem? layoutItem = null; - foreach (var layoutItemJson in layoutItems) + if (layoutItems != null) { - layoutItem = JsonConvert.DeserializeObject(layoutItemJson); - if (layoutItem != null) + foreach (var layoutItemJson in layoutItems) { + layoutItem = JsonConvert.DeserializeObject(layoutItemJson); + if (layoutItem == null) continue; + if (layoutItem.ContentUdi == blockInstance.ContentUdi) { blockInstance.RowSpan = layoutItem.RowSpan!.Value; @@ -127,6 +129,7 @@ public async Task RenderGridBlock( if (item.ContentUdi != blockInstance.ContentUdi) continue; blockInstance.RowSpan = item.RowSpan!.Value; blockInstance.ColumnSpan = item.ColumnSpan!.Value; + break; } } }