Skip to content

Commit 35dc15c

Browse files
authored
Merge pull request #18652 from craftcms/bugfix/18648-matrix-actions-and-read-only-mode
Bugfix/18648 matrix actions and read only mode
2 parents ed7c3a0 + b93a6c9 commit 35dc15c

10 files changed

Lines changed: 36 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
- Fixed a bug where element search query caches weren’t getting invalidated when elements’ search keywords were indexed. ([#18275](https://github.com/craftcms/cms/issues/18275))
99
- Fixed a bug where disabled sites weren’t getting loaded when running Codeception tests. ([#18638](https://github.com/craftcms/cms/issues/18638))
1010
- Fixed a bug where custom entry index page icons weren’t getting stored properly if the source name contained periods. ([#18631](https://github.com/craftcms/cms/issues/18631))
11+
- Fixed a bug where copying nested entries on a revision wasn’t working. ([#18648](https://github.com/craftcms/cms/issues/18648))
12+
- Fixed a bug where Matrix fields in Blocks view could have “Duplicate selected blocks” and “Delete selected blocks” field-level actions. ([#18652](https://github.com/craftcms/cms/pull/18652))
1113

1214
## 5.9.18 - 2026-03-26
1315

src/controllers/AppController.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,11 @@ public function actionRenderElements(): Response
825825
->ownerId($ownerId);
826826
}
827827

828+
// if we have revisionId, then we might need to look through soft-deleted elements too
829+
if (isset($criterion['revisionId'])) {
830+
$query->trashed(null);
831+
}
832+
828833
$elements = $query->all();
829834

830835
// See if there are any provisional changes we should show

src/controllers/ElementsController.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,17 @@ public function actionBulkDuplicate(): ?Response
17291729
->only($element->safeAttributes())
17301730
->all();
17311731

1732+
// if element is a revision, we need to nullify some additional attributes
1733+
if ($element->getIsRevision()) {
1734+
$safeNewAttributes['revisionId'] = null;
1735+
1736+
if ($element->dateDeleted !== null) {
1737+
$safeNewAttributes['dateDeleted'] = null;
1738+
$safeNewAttributes['deletedWithOwner'] = null;
1739+
$safeNewAttributes['trashed'] = false;
1740+
}
1741+
}
1742+
17321743
try {
17331744
$newElement = $elementsService->duplicateElement(
17341745
$element,

src/fields/Matrix.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -980,12 +980,16 @@ private function blockViewActionMenuItems(): array
980980
$entrySelector = ' > .blocks > .matrixblock';
981981

982982
$items[] = $this->copyAction($type, $entrySelector);
983-
$items[] = $this->duplicateAction($type, $entrySelector, <<<JS
983+
if (!$this->static) {
984+
$items[] = $this->duplicateAction($type, $entrySelector, <<<JS
984985
field.data('matrix').duplicateSelectedEntries();
985-
JS);
986-
$items[] = $this->deleteAction($type, $entrySelector, <<<JS
986+
JS
987+
);
988+
$items[] = $this->deleteAction($type, $entrySelector, <<<JS
987989
field.data('matrix').deleteSelectedEntries();
988-
JS);
990+
JS
991+
);
992+
}
989993
}
990994

991995
return $items;
@@ -1003,10 +1007,12 @@ private function cardViewActionMenuItems(): array
10031007
$items[] = $this->copyAction($type, $entrySelector);
10041008
$items[] = $this->duplicateAction($type, $entrySelector, <<<JS
10051009
field.children('.nested-element-cards').data('nestedElementManager').duplicateElements(getEntries());
1006-
JS);
1010+
JS
1011+
);
10071012
$items[] = $this->deleteAction($type, $entrySelector, <<<JS
10081013
field.children('.nested-element-cards').data('nestedElementManager').deleteElements(getEntries());
1009-
JS);
1014+
JS
1015+
);
10101016
}
10111017

10121018
return $items;

src/web/assets/cp/dist/cp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/web/assets/cp/dist/cp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/web/assets/cp/src/js/CP.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,6 +2320,7 @@ Craft.CP.ElementCopyNotification = Craft.CP.Notification.extend({
23202320
type: e.type,
23212321
id: e.id,
23222322
siteId: e.siteId,
2323+
revisionId: e.revisionId ?? null,
23232324
instances: [
23242325
{
23252326
ui: 'chip',

src/web/assets/matrix/dist/MatrixInput.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/web/assets/matrix/dist/MatrixInput.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/web/assets/matrix/src/MatrixInput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205

206206
const entryTypeIds = this.entryTypes.map((entryType) => entryType.id);
207207
for (const info of elementInfo) {
208-
if (!entryTypeIds.includes(info.data.entryTypeId)) {
208+
if (!entryTypeIds.includes(info.data?.entryTypeId)) {
209209
return false;
210210
}
211211
}

0 commit comments

Comments
 (0)