Skip to content

Commit

Permalink
fix: Optional chaining to handle undefined title (#53721)
Browse files Browse the repository at this point in the history
This PR adds safety checks for the `title` property within `reusableBlock`. By using optional chaining, the code now gracefully handles scenarios where `title` might be undefined, preventing a TypeError from being thrown.
  • Loading branch information
Siobhan Bamber authored Aug 16, 2023
1 parent 93413fb commit 618652f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1978,7 +1978,7 @@ export const getInserterItems = createSelector(
id,
name: 'core/block',
initialAttributes: { ref: reusableBlock.id },
title: reusableBlock.title.raw,
title: reusableBlock.title?.raw,
icon,
category: 'reusable',
keywords: [ 'reusable' ],
Expand Down

0 comments on commit 618652f

Please sign in to comment.