Skip to content

Commit 380138e

Browse files
authored
Merge pull request #18185 from craftcms/bugfix/18175-matrix-copy-and-paste
ensure return element
2 parents e9ca7be + 7954b38 commit 380138e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Fixed a bug where chip icons were getting rounded. ([#18163](https://github.com/craftcms/cms/pull/18163))
1111
- Fixed a bug where object templates that included another template were missing variables. ([#18165](https://github.com/craftcms/cms/issues/18165))
1212
- Fixed a JavaScript error that could occur if two control panel animations were triggered simultaneously.
13+
- Fixed a bug where it wasn’t possible to copy/paste nested entries within Matrix fields set to the inline-editable blocks view mode, for unpublished owner elements. ([#18185](https://github.com/craftcms/cms/pull/18185))
1314

1415
## 5.8.21 - 2025-12-04
1516

src/controllers/ElementsController.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2581,7 +2581,10 @@ private function _element(
25812581
$preferSites,
25822582
);
25832583
if ($element && $elementsService->canView($element, $user)) {
2584-
return $this->redirect($element->getCpEditUrl());
2584+
if (!$this->request->getAcceptsJson()) {
2585+
return $this->redirect($element->getCpEditUrl());
2586+
}
2587+
return $element;
25852588
}
25862589
throw new BadRequestHttpException($draftId ? "Invalid draft ID: $draftId" : "Invalid revision ID: $revisionId");
25872590
}
@@ -2608,7 +2611,12 @@ private function _element(
26082611
throw new ForbiddenHttpException('User not authorized to edit this element.');
26092612
}
26102613

2611-
if (!$strictSite && isset($site) && $element->siteId !== $site->id) {
2614+
if (
2615+
!$strictSite &&
2616+
isset($site) &&
2617+
$element->siteId !== $site->id &&
2618+
!$this->request->getAcceptsJson()
2619+
) {
26122620
return $this->redirect($element->getCpEditUrl());
26132621
}
26142622

0 commit comments

Comments
 (0)