Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column Block: enable global template_lock inheritance #42677

Merged
merged 3 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions packages/block-library/src/column/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ import { useSelect, useDispatch } from '@wordpress/data';
import { sprintf, __ } from '@wordpress/i18n';

function ColumnEdit( {
attributes: {
verticalAlignment,
width,
templateLock = false,
allowedBlocks,
},
attributes: { verticalAlignment, width, templateLock, allowedBlocks },
setAttributes,
clientId,
} ) {
Expand Down
30 changes: 15 additions & 15 deletions packages/e2e-tests/specs/editor/plugins/cpt-locking.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,22 @@ describe( 'cpt locking', () => {
);
} );

it( 'can use the global inserter in inner blocks', async () => {
it( 'should not allow blocks to be inserted in inner blocks', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the name of this test is more easier to understand.

await page.click( 'button[aria-label="Two columns; equal split"]' );
await page.click(
'.wp-block-column .block-editor-button-block-appender'
);
await page.type( '.block-editor-inserter__search input', 'image' );
await pressKeyTimes( 'Tab', 2 );
await page.keyboard.press( 'Enter' );
await page.click( '.edit-post-header-toolbar__inserter-toggle' );
await page.type(
'.block-editor-inserter__search input',
'gallery'
);
await pressKeyTimes( 'Tab', 2 );
await page.keyboard.press( 'Enter' );
expect( await page.$( '.wp-block-gallery' ) ).not.toBeNull();
expect(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test expects that the inserter in the column block is not available.

await page.$(
'.wp-block-column .block-editor-button-block-appender'
)
).toBeNull();

expect(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a test to confirm that the global inserter is also disabled.

This code is the same as what we do in shouldDisableTheInserter, but for the sake of clarity, I have copied the code inside verbatim. Without the use of copy, I think it would be difficult to understand what you are trying to do as follows:

it( 'should not allow blocks to be inserted in inner blocks', async () => {
	await page.click( 'button[aria-label="Two columns; equal split"]' );
	expect(
		await page.$(
			'.wp-block-column .block-editor-button-block-appender'
		)
	).toBeNull();

	// Hard to know if we are actually testing or trying to perform some action.
	shouldDisableTheInserter();
} );

await page.evaluate( () => {
const inserter = document.querySelector(
'.edit-post-header [aria-label="Add block"], .edit-post-header [aria-label="Toggle block inserter"]'
);
return inserter.getAttribute( 'disabled' );
} )
).not.toBeNull();
} );
} );

Expand Down