diff --git a/packages/customize-widgets/src/store/selectors.js b/packages/customize-widgets/src/store/selectors.js index abe2cb89c9f6a..b62f7ec1d8709 100644 --- a/packages/customize-widgets/src/store/selectors.js +++ b/packages/customize-widgets/src/store/selectors.js @@ -1,3 +1,8 @@ +const EMPTY_INSERTION_POINT = { + rootClientId: undefined, + insertionIndex: undefined, +}; + /** * Returns true if the inserter is opened. * @@ -35,6 +40,9 @@ export function isInserterOpened( state ) { * @return {Object} The root client ID and index to insert at. */ export function __experimentalGetInsertionPoint( state ) { - const { rootClientId, insertionIndex } = state.blockInserterPanel; - return { rootClientId, insertionIndex }; + if ( typeof state === 'boolean' ) { + return EMPTY_INSERTION_POINT; + } + + return state.blockInserterPanel; } diff --git a/packages/edit-post/src/store/selectors.js b/packages/edit-post/src/store/selectors.js index 5ae7d6b4437b7..a30bcc188b496 100644 --- a/packages/edit-post/src/store/selectors.js +++ b/packages/edit-post/src/store/selectors.js @@ -15,6 +15,11 @@ import deprecated from '@wordpress/deprecated'; const EMPTY_ARRAY = []; const EMPTY_OBJECT = {}; +const EMPTY_INSERTION_POINT = { + rootClientId: undefined, + insertionIndex: undefined, + filterValue: undefined, +}; /** * Returns the current editing mode. @@ -472,9 +477,11 @@ export function isInserterOpened( state ) { * @return {Object} The root client ID, index to insert at and starting filter value. */ export function __experimentalGetInsertionPoint( state ) { - const { rootClientId, insertionIndex, filterValue } = - state.blockInserterPanel; - return { rootClientId, insertionIndex, filterValue }; + if ( typeof state === 'boolean' ) { + return EMPTY_INSERTION_POINT; + } + + return state.blockInserterPanel; } /** diff --git a/packages/edit-widgets/src/store/selectors.js b/packages/edit-widgets/src/store/selectors.js index 80bcddfead7b3..63f33475eb3c5 100644 --- a/packages/edit-widgets/src/store/selectors.js +++ b/packages/edit-widgets/src/store/selectors.js @@ -19,6 +19,11 @@ import { } from './utils'; import { STORE_NAME as editWidgetsStoreName } from './constants'; +const EMPTY_INSERTION_POINT = { + rootClientId: undefined, + insertionIndex: undefined, +}; + /** * Returns all API widgets. * @@ -254,8 +259,11 @@ export function isInserterOpened( state ) { * @return {Object} The root client ID and index to insert at. */ export function __experimentalGetInsertionPoint( state ) { - const { rootClientId, insertionIndex } = state.blockInserterPanel; - return { rootClientId, insertionIndex }; + if ( typeof state === 'boolean' ) { + return EMPTY_INSERTION_POINT; + } + + return state.blockInserterPanel; } /**