Skip to content

Commit 1f6d69f

Browse files
committed
fix: include parent children to render set when adding new blocks for live preview
1 parent 5567d20 commit 1f6d69f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Http/Controllers/Admin/ThemeEditorController.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,16 +372,21 @@ protected function getVisualThemes(): array
372372
protected function buildRenderSet(array $updates, array $loadedBlocks): array
373373
{
374374
$changes = $updates['changes'] ?? [];
375-
$changedIds = array_merge(
376-
$changes['added'] ?? [],
377-
$changes['updated'] ?? []
378-
);
375+
$addedIds = $changes['added'] ?? [];
376+
$updatedIds = $changes['updated'] ?? [];
377+
$changedIds = array_merge($addedIds, $updatedIds);
379378

380379
$renderSet = [];
381380

382381
foreach ($changedIds as $id) {
383382
$renderSet[] = $id;
384383

384+
// If block is in added and has a parent, include parent's children
385+
if (in_array($id, $addedIds) && isset($loadedBlocks[$id]['parentId']) && $loadedBlocks[$id]['parentId']) {
386+
$parentId = $loadedBlocks[$id]['parentId'];
387+
$this->addChildren($parentId, $loadedBlocks, $renderSet);
388+
}
389+
385390
// Walk up parent chain
386391
$currentId = $id;
387392
while (isset($loadedBlocks[$currentId]['parentId']) && $loadedBlocks[$currentId]['parentId']) {

0 commit comments

Comments
 (0)