Skip to content

Commit

Permalink
Fix uncaught TypeError in Columns block (#14605)
Browse files Browse the repository at this point in the history
* ensure there’s accounting for object being undefined.
* add changelog entry
  • Loading branch information
nerrad authored Mar 25, 2019
1 parent 4c0d219 commit f779b93
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/block-library/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion packages/block-library/src/columns/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } ) => {
Expand Down

0 comments on commit f779b93

Please sign in to comment.