Skip to content

Commit

Permalink
Fix position value for blocks in non-default editors
Browse files Browse the repository at this point in the history
  • Loading branch information
joyceverheije authored Dec 8, 2023
1 parent 5bddccf commit 7081d29
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Repositories/Behaviors/HandleBlocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,17 @@ private function getBlocks($object, $fields)
{
$blocks = Collection::make();
if (isset($fields['blocks']) && is_array($fields['blocks'])) {
foreach ($fields['blocks'] as $index => $block) {
$block = $this->buildBlock($block, $object);
foreach (collect($fields['blocks'])->groupBy('editor_name')->values()->toArray() as $editorBlocks) {
foreach ($editorBlocks as $index => $block) {
$block = $this->buildBlock($block, $object);

$this->validateBlockArray($block, $block['instance'], true);
$this->validateBlockArray($block, $block['instance'], true);

$block['position'] = $index + 1;
$block['blocks'] = $this->getChildBlocks($object, $block);
$block['position'] = $index + 1;
$block['blocks'] = $this->getChildBlocks($object, $block);

$blocks->push($block);
$blocks->push($block);
}
}
}

Expand Down

0 comments on commit 7081d29

Please sign in to comment.