From ef82afd95d6373061bc65fef65a782c60f4677cd Mon Sep 17 00:00:00 2001 From: Michael Joseph Panaga Date: Mon, 26 Aug 2019 22:57:27 +0800 Subject: [PATCH] Fix: Empty Classic Editor inside innerBlock fatal error (#17164) * Fix: Empty Classic Editor insider innerBlock fatal error * Expand inline comment --- packages/blocks/src/api/parser.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/blocks/src/api/parser.js b/packages/blocks/src/api/parser.js index 0e67b0219142d..f408df969a0b9 100644 --- a/packages/blocks/src/api/parser.js +++ b/packages/blocks/src/api/parser.js @@ -457,6 +457,12 @@ export function createBlockWithFallback( blockNode ) { // Coerce inner blocks from parsed form to canonical form. innerBlocks = innerBlocks.map( createBlockWithFallback ); + // Remove `undefined` innerBlocks. + // + // This is a temporary fix to prevent unrecoverable TypeErrors when handling unexpectedly + // empty freeform block nodes. See https://github.com/WordPress/gutenberg/pull/17164. + innerBlocks = innerBlocks.filter( ( innerBlock ) => innerBlock ); + const isFallbackBlock = ( name === freeformContentFallbackBlock || name === unregisteredFallbackBlock