Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Fixed an error that could occur when loading control panel resources on the front end.
- Fixed a bug where entries’ section breadcrumbs were getting hyperlinked even if the section’s source was disabled. ([#17411](https://github.com/craftcms/cms/issues/17411))
- Fixed a bug where entries that were pasted within a Matrix field were losing custom field translations for other sites. ([17414](https://github.com/craftcms/cms/issues/17414))
- Fixed a bug where Matrix fields’ chips were getting “Copy all entries” actions. ([#17404](https://github.com/craftcms/cms/issues/17404))

## 5.7.10 - 2025-06-04

Expand Down
74 changes: 41 additions & 33 deletions src/fields/Matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -837,43 +837,51 @@ protected function actionMenuItems(): array
];

if ($this->viewMode === self::VIEW_MODE_CARDS) {
$view->registerJsWithVars(fn($copyAllId, $fieldId) => <<<JS
(() => {
$('#' + $copyAllId).on('activate', () => {
Craft.cp.copyElements($('#' + $fieldId + ' > .nested-element-cards > .elements > li > .element'));
});
})();
JS, [
$view->namespaceInputId($copyAllId),
$view->namespaceInputId($this->getInputId()),
]);
$copyAllJs = <<<JS
copyAllBtn.on('activate', () => {
Craft.cp.copyElements(field.find('> .nested-element-cards > .elements > li > .element'));
});
JS;
} else {
$view->registerJsWithVars(fn($copyAllId, $fieldId, $baseInfo) => <<<JS
(() => {
$('#' + $copyAllId).on('activate', () => {
const elementInfo = [];
$('#' + $fieldId + ' > .blocks > .matrixblock').each((i, element) => {
element = $(element);
elementInfo.push(Object.assign({
id: element.data('id'),
draftId: element.data('draftId'),
revisionId: element.data('revisionId'),
ownerId: element.data('ownerId'),
siteId: element.data('siteId'),
}, $baseInfo));
});
Craft.cp.copyElements(elementInfo);
$baseInfo = Json::encode([
'type' => Entry::class,
'fieldId' => $this->id,
]);
$copyAllJs = <<<JS
copyAllBtn.on('activate', () => {
const elementInfo = [];
field.find('> .blocks > .matrixblock').each((i, element) => {
element = $(element);
elementInfo.push(Object.assign({
id: element.data('id'),
draftId: element.data('draftId'),
revisionId: element.data('revisionId'),
ownerId: element.data('ownerId'),
siteId: element.data('siteId'),
}, $baseInfo));
});
Craft.cp.copyElements(elementInfo);
});
JS;
}

$view->registerJsWithVars(fn($copyAllId, $fieldId) => <<<JS
(() => {
const copyAllBtn = $('#' + $copyAllId);
const field = $('#' + $fieldId);
if (field.length) {
$copyAllJs
} else {
setTimeout(() => {
const menu = copyAllBtn.closest('.menu').data('disclosureMenu');
menu.removeItem(copyAllBtn[0]);
}, 1);
}
})();
JS, [
$view->namespaceInputId($copyAllId),
$view->namespaceInputId($this->getInputId()),
[
'type' => Entry::class,
'fieldId' => $this->id,
],
]);
}
$view->namespaceInputId($copyAllId),
$view->namespaceInputId($this->getInputId()),
]);
}

$parentItems = parent::actionMenuItems();
Expand Down
Loading