Skip to content

Conversation

@i-just
Copy link
Contributor

@i-just i-just commented Dec 18, 2025

Description

When a new nested entry is created for the matrix field in inline-editable blocks mode, it’s first created as a draft and so has a draftId. That new entry, with draftId, is passed back to the view and rendered. Then the owner element is auto-saved, triggering NestedElementManager->saveNestedElements(), which triggers the Drafts->removeDraftData(), which causes the draftId for that matrix “block” to be nullified.

If you then use the “copy” element action without reloading the page, the element data will contain the draftId that’s no longer applicable. When pasting, the canonical element is still found, but instead of being returned, we redirect to its control panel URL, causing the described issue.

Fix: when triggering the “copy” action, the element info can contain an extra ensureReturnElement param, which, when set to true, will enforce the element being returned instead of the redirect.

Related issues

#18175

@i-just i-just requested a review from brandonkelly December 18, 2025 10:22
@brandonkelly
Copy link
Member

Went with a check to $this->request->getAcceptsJson() instead (to see if it’s an Ajax request), since there’s never a case where an Ajax request should get a redirect response to the element’s edit page.

@brandonkelly brandonkelly merged commit 380138e into 5.x Dec 19, 2025
7 checks passed
@brandonkelly brandonkelly deleted the bugfix/18175-matrix-copy-and-paste branch December 19, 2025 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants