Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matrix field amends #14915

Merged
merged 6 commits into from
May 1, 2024
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,9 @@
## Unreleased

- Fixed a bug where disclosure menus weren’t releasing their `scroll` and `resize` event listeners on hide. ([#14911](https://github.com/craftcms/cms/pull/14911]), [#14510](https://github.com/craftcms/cms/issues/14510))
- Fixed a bug where it was possible to delete entries from Matrix fields which were configured to display nested entries statically. ([#14904](https://github.com/craftcms/cms/issues/14904), [#14915](https://github.com/craftcms/cms/pull/14915))
- Fixed an error that could occur when creating a nested entry in a Matrix field. ([#14915](https://github.com/craftcms/cms/pull/14915))
- Fixed a bug where action buttons might not work for nested entries in Matrix fields set to card view. ([#14915](https://github.com/craftcms/cms/pull/14915))

## 5.1.0 - 2024-04-30

8 changes: 7 additions & 1 deletion src/controllers/ElementsController.php
Original file line number Diff line number Diff line change
@@ -1439,9 +1439,15 @@ public function actionSaveDraft(): ?Response
{
$this->requirePostRequest();

/** @var Element|DraftBehavior|null $element */
/** @var Element|DraftBehavior|Response|null $element */
$element = $this->_element();

// this can happen if we're creating e.g. nested entry in a matrix field (cards or element index)
// and we hit "create entry" before the autosave kicks in
if ($element instanceof Response) {
return $element;
}

if (!$element || $element->getIsRevision()) {
throw new BadRequestHttpException('No element was identified by the request.');
}
2 changes: 2 additions & 0 deletions src/controllers/MatrixController.php
Original file line number Diff line number Diff line change
@@ -78,6 +78,7 @@ public function actionCreateEntry(): Response
$ownerElementType = $this->request->getRequiredBodyParam('ownerElementType');
$siteId = $this->request->getRequiredBodyParam('siteId');
$namespace = $this->request->getRequiredBodyParam('namespace');
$staticEntries = $this->request->getBodyParam('staticEntries', false);

$elementsService = Craft::$app->getElements();
$owner = $elementsService->getElementById($ownerId, $ownerElementType, $siteId);
@@ -135,6 +136,7 @@ public function actionCreateEntry(): Response
'entryTypes' => $field->getEntryTypesForField($entries, $owner),
'entry' => $entry,
'isFresh' => true,
'staticEntries' => $staticEntries,
]), $namespace);

return $this->asJson([
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js.map

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions src/web/assets/cp/src/js/NestedElementManager.js
Original file line number Diff line number Diff line change
@@ -394,12 +394,13 @@ Craft.NestedElementManager = Garnish.Base.extend(
this.elementSort.addItems($element.parent());
}

const $actionMenuBtn = $element.find('.action-btn');
const disclosureMenu = $actionMenuBtn
.disclosureMenu()
.data('disclosureMenu');
const $actionMenu = disclosureMenu.$container;

if (Garnish.hasAttr($element, 'data-deletable')) {
const $actionMenuBtn = $element.find('.action-btn');
const disclosureMenu = $actionMenuBtn
.disclosureMenu()
.data('disclosureMenu');
const $actionMenu = disclosureMenu.$container;
$('<hr/>', {class: 'padded'}).appendTo($actionMenu);
const $ul = $('<ul/>').appendTo($actionMenu);
const $li = $('<li/>').appendTo($ul);
2 changes: 1 addition & 1 deletion src/web/assets/matrix/dist/MatrixInput.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/matrix/dist/MatrixInput.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/web/assets/matrix/src/MatrixInput.js
Original file line number Diff line number Diff line change
@@ -252,6 +252,7 @@ import $ from 'jquery';
ownerElementType: this.settings.ownerElementType,
siteId: this.settings.siteId,
namespace: this.settings.namespace,
staticEntries: this.settings.staticEntries,
},
}
);