Skip to content

Commit

Permalink
Fix slideout new block values not being saved for conditionally-shown…
Browse files Browse the repository at this point in the history
… fields
  • Loading branch information
ttempleton committed Dec 3, 2023
1 parent 1f415d1 commit 3ba1685
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Unreleased

### Fixed
- Fixed a bug when lazy loading new blocks in a slideout element editor, where the values of new blocks' fields affected by condition rules weren't being saved

## 3.9.9 - 2023-11-24

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/assets/dist/neo-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/assets/dist/neo-main.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/assets/src/input/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,9 @@ export default Garnish.Base.extend({

elementEditor.pause()
const siteId = elementEditor.settings.siteId
NS.enter(this.getNamespace())
const data = {
namespace: NS.toFieldName(),
blocks: {},
sortOrder: [],
fieldId: this._id,
Expand All @@ -858,6 +860,7 @@ export default Garnish.Base.extend({
isProvisionalDraft: elementEditor.settings.isProvisionalDraft,
siteId
}
NS.leave()
const originalBlockIds = {}
this._blocks.forEach((block) => {
const selectedTabId = block.$contentContainer
Expand Down
7 changes: 4 additions & 3 deletions src/controllers/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public function actionUpdateVisibleElements(): Response
$sortOrder = $request->getRequiredBodyParam('sortOrder');

$field = $fieldsService->getFieldById($fieldId);
$namespace = $request->getBodyParam('namespace', "fields[{$field->handle}][blocks]");
$canonicalOwner = $elementsService->getElementById($ownerCanonicalId, null, $siteId);
$draftsQueryMethod = $isProvisionalDraft ? 'provisionalDrafts' : 'drafts';

Expand Down Expand Up @@ -245,10 +246,10 @@ public function actionUpdateVisibleElements(): Response
}

$view = Craft::$app->getView();
$namespace = "fields[{$field->handle}][blocks][{$blockId}]";
$blockNamespace = "{$namespace}[{$blockId}]";
$fieldLayout = $block->getFieldLayout();
$form = $fieldLayout->createForm($block, false, [
'namespace' => $namespace,
'namespace' => $blockNamespace,
'registerDeltas' => false,
'visibleElements' => $blockData['visibleLayoutElements'],
]);
Expand Down Expand Up @@ -304,7 +305,7 @@ public function actionUpdateVisibleElements(): Response
'tabs' => $tabs,
'selectedTab' => $selectedTab,
'block' => $block,
], View::TEMPLATE_MODE_CP), $namespace);
], View::TEMPLATE_MODE_CP), $blockNamespace);
} else {
$tabHtml = null;
}
Expand Down

0 comments on commit 3ba1685

Please sign in to comment.