diff --git a/application/asset/js/site-page-edit.js b/application/asset/js/site-page-edit.js index cc38bc32d..16267dc72 100644 --- a/application/asset/js/site-page-edit.js +++ b/application/asset/js/site-page-edit.js @@ -515,25 +515,34 @@ // Preview the page layout grid. const previewPageLayoutGrid = function() { - const gridLayoutPreview = $('#grid-layout-preview'); + const previewDiv = $('#grid-layout-preview'); const gridColumns = parseInt($('#page-layout-grid-columns-select').val(), 10); - gridLayoutPreview - .empty() - .css('grid-template-columns', `repeat(${gridColumns}, 1fr)`); + previewDiv.css('grid-template-columns', `repeat(${gridColumns}, 1fr)`).empty(); + let inBlockGroup = false; + let blockGroupSpan; + let blockGroupCurrentSpan; + let blockGroupDiv; $('.block').each(function() { const thisBlock = $(this); const blockLayout = thisBlock.data('block-layout'); if ('blockGroup' == blockLayout) { - const blockGroupSpan = thisBlock.find('.block-group-span').val(); - // @todo: fix preview to account for groups (use PageLayout::render() for example code) + // The blockGroup block gets special treatment. + if (inBlockGroup) { + // Blocks may not overlap. + previewDiv.append(blockGroupDiv); + } + inBlockGroup = true; + blockGroupSpan = parseInt(thisBlock.find('.block-group-span').val(), 10); + blockGroupCurrentSpan = 0; + blockGroupDiv = $(`