Skip to content

Commit

Permalink
Fix parent block field condition rules not always being applied
Browse files Browse the repository at this point in the history
  • Loading branch information
ttempleton committed May 14, 2024
1 parent 32f82fa commit b4aa37d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixed
- Fixed a bug where swapping the positions of new Neo blocks could cause a mixup of field layout elements and content loss
- Fixed an error that could occur when updating visible field layout elements after the first change to an entry
- Fixed a bug where condition rules for parent block field values were not always being applied

## 4.1.2 - 2024-04-09

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.

8 changes: 6 additions & 2 deletions src/assets/src/input/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ export default Garnish.Base.extend({
this.$form.data('elementEditor')?.resume()
this._updateBlockOrder()
this._updateButtons()
this._updateAllVisibleElements()
}
})

Expand Down Expand Up @@ -837,7 +836,11 @@ export default Garnish.Base.extend({
* @private
*/
_registerDynamicBlockConditions () {
this._formObserver = new Craft.FormObserver(this.$form, () => this._updateAllVisibleElements())
// A small timeout to let the element editor initialise
setTimeout(
() => this.$form.data('elementEditor')?.on('update', () => this._updateAllVisibleElements()),
200
)
},

async _updateAllVisibleElements () {
Expand Down Expand Up @@ -1143,6 +1146,7 @@ export default Garnish.Base.extend({

this._removeSpinner()
this.addBlock(block, e.index, e.level, e.createChildBlocks, e.createChildBlocks)
this._updateAllVisibleElements()
}

if (e.blockType.getTabs() !== null) {
Expand Down

0 comments on commit b4aa37d

Please sign in to comment.