diff --git a/packages/block-editor/src/store/selectors.js b/packages/block-editor/src/store/selectors.js index 2ebbb5c2e8e13b..30cf032ce36f4f 100644 --- a/packages/block-editor/src/store/selectors.js +++ b/packages/block-editor/src/store/selectors.js @@ -1215,7 +1215,17 @@ export function getBlockInsertionPoint( state ) { * @return {?boolean} Whether the insertion point is visible or not. */ export function isBlockInsertionPointVisible( state ) { - return state.insertionPoint !== null; + const insertionPoint = state.insertionPoint; + + if ( ! state.insertionPoint ) { + return false; + } + + if ( getTemplateLock( state, insertionPoint.rootClientId ) ) { + return false; + } + + return true; } /** diff --git a/packages/block-editor/src/store/test/selectors.js b/packages/block-editor/src/store/test/selectors.js index 0e67cc0f1d5515..40194fad3c5c6b 100644 --- a/packages/block-editor/src/store/test/selectors.js +++ b/packages/block-editor/src/store/test/selectors.js @@ -2255,12 +2255,43 @@ describe( 'selectors', () => { expect( isBlockInsertionPointVisible( state ) ).toBe( false ); } ); + it( 'should return false if the rootClientId has a truthy template lock', () => { + const state = { + insertionPoint: { + rootClientId: 'testClientId', + index: 5, + }, + blockListSettings: { + testClientId: { + templateLock: 'all', + }, + }, + }; + + expect( isBlockInsertionPointVisible( state ) ).toBe( false ); + } ); + + it( 'should return false if the rootClientId is undefined, and the settings has a template lock', () => { + const state = { + insertionPoint: { + rootClientId: undefined, + index: 5, + }, + settings: { + templateLock: 'all', + }, + }; + + expect( isBlockInsertionPointVisible( state ) ).toBe( false ); + } ); + it( 'should return true if assigned insertion point', () => { const state = { insertionPoint: { rootClientId: undefined, index: 5, }, + settings: {}, }; expect( isBlockInsertionPointVisible( state ) ).toBe( true );