diff --git a/packages/block-library/CHANGELOG.md b/packages/block-library/CHANGELOG.md index 34ac5b9d4807d9..30a19230105eaa 100644 --- a/packages/block-library/CHANGELOG.md +++ b/packages/block-library/CHANGELOG.md @@ -2,6 +2,10 @@ - Add vertical alignment controls to `columns` Block ([#13899](https://github.com/WordPress/gutenberg/pull/13899/)). +### Bug Fixes + +- fix uncaught error in `columns` block due to accessing a property on an object that might be undefined [#14605](https://github.com/WordPress/gutenberg/pull/14605) + ## 2.3.0 (2019-03-06) ### New Feature diff --git a/packages/block-library/src/columns/edit.js b/packages/block-library/src/columns/edit.js index af5431807645d4..206b313427cf99 100644 --- a/packages/block-library/src/columns/edit.js +++ b/packages/block-library/src/columns/edit.js @@ -82,15 +82,18 @@ export const ColumnsEdit = function( { attributes, setAttributes, className, upd ); }; +const DEFAULT_EMPTY_ARRAY = []; + export default compose( /** * Selects the child column Blocks for this parent Column */ withSelect( ( select, { clientId } ) => { const { getBlocksByClientId } = select( 'core/editor' ); + const block = getBlocksByClientId( clientId )[ 0 ]; return { - childColumns: getBlocksByClientId( clientId )[ 0 ].innerBlocks, + childColumns: block ? block.innerBlocks : DEFAULT_EMPTY_ARRAY, }; } ), withDispatch( ( dispatch, { clientId, childColumns } ) => {