Skip to content

Commit

Permalink
Merge pull request #477 from mmikkel/mmikkel-patch-1
Browse files Browse the repository at this point in the history
Make sure sort order is updated when block ownership is duplicated
  • Loading branch information
engram-design authored Jun 11, 2022
2 parents 2e95173 + c352a43 commit 435a605
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/services/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -869,14 +869,14 @@ public function duplicateBlocks(SuperTableField $field, ElementInterface $source
} else {
$newBlockId = $block->getCanonicalId();
}
} elseif ($block->primaryOwnerId === $target->id) {
// Only the block ownership was duplicated, so just update its sort order for the target element
Db::update('{{%supertableblocks_owners}}', [
'sortOrder' => $block->sortOrder,
], ['blockId' => $block->id, 'ownerId' => $target->id], updateTimestamp: false);
$newBlockId = $block->id;
} else {
// If the block’s primary owner is equal to the target element ID, no need to do anything
if ($block->primaryOwnerId !== $target->id) {
/** @var SuperTableBlockElement $newBlock */
$newBlockId = $elementsService->duplicateElement($block, $newAttributes)->id;
} else {
$newBlockId = $block->id;
}
$newBlockId = $elementsService->duplicateElement($block, $newAttributes)->id;
}

$newBlockIds[] = $newBlockId;
Expand Down

0 comments on commit 435a605

Please sign in to comment.