Skip to content

Commit

Permalink
Fix new block type settings/FLD not loading after validation error
Browse files Browse the repository at this point in the history
  • Loading branch information
ttempleton committed Apr 8, 2024
1 parent 75652d9 commit 230f9ad
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 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 validation errors occurred on new block types when trying to save a Neo field, where the new block types' settings and field layout designer would not load when selected

## 4.1.0 - 2024-04-03

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions src/assets/src/configurator/BlockType.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import BlockTypeFieldLayout from './BlockTypeFieldLayout'

const _defaults = {
namespace: [],
fieldLayout: null
fieldLayout: null,
alreadyLoaded: false
}

export default Item.extend({
Expand All @@ -23,6 +24,7 @@ export default Item.extend({
this._templateNs = NS.parse(settings.namespace)
this._field = settings.field
this._fieldLayout = settings.fieldLayout
this._loaded = settings.alreadyLoaded
const sidebarItem = this.getField()?.$sidebarContainer.find(`[data-neo-bt="container.${this.getId()}`)

if (sidebarItem?.length > 0) {
Expand All @@ -37,11 +39,6 @@ export default Item.extend({
this.$moveButton = $neo.filter('[data-neo-bt="button.move"]')
this.$actionsButton = $neo.filter('[data-neo-bt="button.actions"]')

// If new block type, set settings / field layout designer as already loaded
if (/^new([0-9]+)$/.test(String(this.getId()))) {
this._loaded = true
}

// Set up the actions menu
this.$actionsButton.menubtn()
this._actionsMenu = this.$actionsButton.data('menubtn')
Expand Down
7 changes: 4 additions & 3 deletions src/assets/src/configurator/Configurator.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ export default Garnish.Base.extend({
})

this.$blockTypesContainer.find('.type-spinner').remove()
this._initBlockType(namespace, settings, fieldLayout, selectedIndex)
this._initBlockType(namespace, settings, fieldLayout, selectedIndex, true)
resolve()
})
.catch(reject)
Expand All @@ -460,12 +460,13 @@ export default Garnish.Base.extend({
}
},

_initBlockType (namespace, settings, fieldLayout, index) {
_initBlockType (namespace, settings, fieldLayout, index, alreadyLoaded = false) {
const blockType = new BlockType({
namespace,
field: this,
settings,
fieldLayout
fieldLayout,
alreadyLoaded
})

this.addItem(blockType, index)
Expand Down

0 comments on commit 230f9ad

Please sign in to comment.