From 2c55abb80fd1ee6dfee155b6e0e7dc43300b66bb Mon Sep 17 00:00:00 2001 From: Giulia Ghisini <51911425+giuliaghisini@users.noreply.github.com> Date: Tue, 24 Sep 2024 11:26:20 +0200 Subject: [PATCH] Fixed find blocks method if fieldname is similiar to 'blocks' (#6299) --- packages/volto/news/6299.bugfix | 1 + packages/volto/src/helpers/Blocks/Blocks.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 packages/volto/news/6299.bugfix diff --git a/packages/volto/news/6299.bugfix b/packages/volto/news/6299.bugfix new file mode 100644 index 0000000000..0d8ad4608a --- /dev/null +++ b/packages/volto/news/6299.bugfix @@ -0,0 +1 @@ +Fixed findBlocks when no blocks are passed. @giuliaghisini diff --git a/packages/volto/src/helpers/Blocks/Blocks.js b/packages/volto/src/helpers/Blocks/Blocks.js index 88f1a5ed15..6b24de9080 100644 --- a/packages/volto/src/helpers/Blocks/Blocks.js +++ b/packages/volto/src/helpers/Blocks/Blocks.js @@ -718,7 +718,7 @@ export function isBlockContainer(block) { * @param {Object} types A list with the list of types to be matched * @return {Array} An array of block ids */ -export function findBlocks(blocks, types, result = []) { +export function findBlocks(blocks = {}, types, result = []) { Object.keys(blocks).forEach((blockId) => { const block = blocks[blockId]; // check blocks from data as well since some add-ons use that