Skip to content

Commit

Permalink
Fix editor name for blocks inside repeaters
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofandel committed Apr 1, 2024
1 parent 60fcf11 commit ba544dd
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions frontend/js/utils/getFormData.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ export const isBlockField = (name, id) => {
}

export const stripOutBlockNamespace = (name, id) => {
const nameWithoutBlock = name.replace('blocks[' + id + '][', '')
return nameWithoutBlock.match(/]/gi).length > 1 ? nameWithoutBlock.replace(']', '') : nameWithoutBlock.slice(0, -1)
return name.replace('blocks[' + id + '][', '').replace(']', '')
}

export const buildBlock = (block, rootState, isRepeater = false, isInsideRepeater = isRepeater) => {
Expand Down Expand Up @@ -81,7 +80,7 @@ export const buildBlock = (block, rootState, isRepeater = false, isInsideRepeate
}
return isInsideRepeater
? { ...content, ...base, repeater_target_id: block.repeater_target_id, blocks, repeaters}
: { ...base, content, is_repeater: isRepeater, type: block.type, editor_name: block.name, blocks: {...blocks, ...repeaters} }
: { ...base, content, is_repeater: isRepeater, type: block.type, editor_name: block.name?.split('|').pop(), blocks: {...blocks, ...repeaters} }
}

export const isBlockEmpty = (blockData) => {
Expand Down

0 comments on commit ba544dd

Please sign in to comment.