From abb51bab2b12c82d271ec206b93065edf45fd624 Mon Sep 17 00:00:00 2001 From: Siobhan Date: Wed, 16 Aug 2023 10:14:55 +0100 Subject: [PATCH] fix: Optional chaining to handle undefined title This commit 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. --- packages/block-editor/src/store/selectors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-editor/src/store/selectors.js b/packages/block-editor/src/store/selectors.js index 76bcecf9da576..3c961c130b78a 100644 --- a/packages/block-editor/src/store/selectors.js +++ b/packages/block-editor/src/store/selectors.js @@ -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' ],