Skip to content

Commit 0c28912

Browse files
joyceverheijeifox
authored andcommitted
Fix position value for blocks in non-default editors
1 parent 4c35efb commit 0c28912

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/Repositories/Behaviors/HandleBlocks.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,17 @@ private function getBlocks($object, $fields)
244244
{
245245
$blocks = Collection::make();
246246
if (isset($fields['blocks']) && is_array($fields['blocks'])) {
247-
foreach ($fields['blocks'] as $index => $block) {
248-
$block = $this->buildBlock($block, $object);
247+
foreach (collect($fields['blocks'])->groupBy('editor_name')->values()->toArray() as $editorBlocks) {
248+
foreach ($editorBlocks as $index => $block) {
249+
$block = $this->buildBlock($block, $object);
249250

250-
$this->validateBlockArray($block, $block['instance'], true);
251+
$this->validateBlockArray($block, $block['instance'], true);
251252

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

255-
$blocks->push($block);
256+
$blocks->push($block);
257+
}
256258
}
257259
}
258260

0 commit comments

Comments
 (0)