From 4d5d02024e31f7601799608946faaf225e125257 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Tue, 19 Sep 2023 21:27:05 +0400 Subject: [PATCH 1/3] Fix selector dependencies --- packages/block-editor/src/store/private-selectors.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/store/private-selectors.js b/packages/block-editor/src/store/private-selectors.js index e77e478ba6046..f96f91fa2a905 100644 --- a/packages/block-editor/src/store/private-selectors.js +++ b/packages/block-editor/src/store/private-selectors.js @@ -58,7 +58,12 @@ export const isBlockSubtreeDisabled = createSelector( getBlockOrder( state, clientId ).every( isChildSubtreeDisabled ) ); }, - ( state ) => [ state.blockEditingModes, state.blocks.parents ] + ( state ) => [ + state.blocks.parents, + state.blocks.order, + state.blockEditingModes, + state.blockListSettings, + ] ); /** From 37bb668bdb137d5e37db3f68c0cd5e7934cb1aca Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Tue, 19 Sep 2023 21:27:24 +0400 Subject: [PATCH 2/3] Improve child subtree check --- packages/block-editor/src/store/private-selectors.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/block-editor/src/store/private-selectors.js b/packages/block-editor/src/store/private-selectors.js index f96f91fa2a905..698da537728e0 100644 --- a/packages/block-editor/src/store/private-selectors.js +++ b/packages/block-editor/src/store/private-selectors.js @@ -45,9 +45,8 @@ export function getLastInsertedBlocksClientIds( state ) { export const isBlockSubtreeDisabled = createSelector( ( state, clientId ) => { const isChildSubtreeDisabled = ( childClientId ) => { - const mode = state.blockEditingModes.get( childClientId ); return ( - ( mode === undefined || mode === 'disabled' ) && + getBlockEditingMode( state, childClientId ) === 'disabled' && getBlockOrder( state, childClientId ).every( isChildSubtreeDisabled ) From 440de7f9c19b8793993764c7f3ecb529ff06c9c2 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 20 Sep 2023 12:00:01 +0400 Subject: [PATCH 3/3] Add e2e tests --- .../editor/various/content-only-lock.spec.js | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/e2e/specs/editor/various/content-only-lock.spec.js b/test/e2e/specs/editor/various/content-only-lock.spec.js index d6ea152d65f3f..8e07741db29b1 100644 --- a/test/e2e/specs/editor/various/content-only-lock.spec.js +++ b/test/e2e/specs/editor/various/content-only-lock.spec.js @@ -29,4 +29,49 @@ test.describe( 'Content-only lock', () => { await page.keyboard.type( ' World' ); expect( await editor.getEditedPostContent() ).toMatchSnapshot(); } ); + + // See: https://github.com/WordPress/gutenberg/pull/54618 + test( 'should be able to edit the content of deeply nested blocks', async ( { + editor, + page, + pageUtils, + } ) => { + // Add content only locked block in the code editor + await pageUtils.pressKeys( 'secondary+M' ); // Emulates CTRL+Shift+Alt + M => toggle code editor + + await page.getByPlaceholder( 'Start writing with text or HTML' ) + .fill( ` +
+
+

Hello

+
+
+` ); + + await pageUtils.pressKeys( 'secondary+M' ); + await page.waitForSelector( 'iframe[name="editor-canvas"]' ); + await editor.canvas.click( 'role=document[name="Paragraph block"i]' ); + await page.keyboard.type( ' WP' ); + await expect.poll( editor.getBlocks ).toMatchObject( [ + { + name: 'core/group', + attributes: { + layout: { type: 'constrained' }, + templateLock: 'contentOnly', + }, + innerBlocks: [ + { + name: 'core/group', + attributes: { layout: { type: 'constrained' } }, + innerBlocks: [ + { + name: 'core/paragraph', + attributes: { content: 'Hello WP' }, + }, + ], + }, + ], + }, + ] ); + } ); } );