Skip to content

Commit 3ac2fe5

Browse files
Mamadukaandrewserongtalldangziolonoisysocks
authored
Block Editor: Update conditions for displaying the empty block inserter (#70897)
* Block Editor: Update conditions for displaying the empty block inserter * Fix the Cover block unit tests * Improve post-type locking e2e tests Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org> Co-authored-by: gziolo <gziolo@git.wordpress.org> Co-authored-by: noisysocks <noisysocks@git.wordpress.org> Co-authored-by: desrosj <desrosj@git.wordpress.org> Co-authored-by: albanyacademy <brumack@git.wordpress.org>
1 parent 8f9c570 commit 3ac2fe5

File tree

4 files changed

+18
-28
lines changed

4 files changed

+18
-28
lines changed

packages/block-editor/src/components/block-tools/use-show-block-tools.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function useShowBlockTools() {
3636
const hasSelectedBlock = !! clientId && !! block;
3737
const isEmptyDefaultBlock =
3838
hasSelectedBlock &&
39-
isUnmodifiedDefaultBlock( block ) &&
39+
isUnmodifiedDefaultBlock( block, 'content' ) &&
4040
getBlockMode( clientId ) !== 'html';
4141
const _showEmptyBlockSideInserter =
4242
clientId &&

packages/block-editor/src/components/inserter/hooks/use-insertion-point.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function useInsertionPoint( {
151151
if (
152152
! isAppender &&
153153
selectedBlock &&
154-
isUnmodifiedDefaultBlock( selectedBlock )
154+
isUnmodifiedDefaultBlock( selectedBlock, 'content' )
155155
) {
156156
replaceBlocks(
157157
selectedBlock.clientId,

packages/block-library/src/cover/test/edit.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,7 @@ async function createAndSelectBlock() {
5151
name: 'Black',
5252
} )
5353
);
54-
await userEvent.click(
55-
screen.getByRole( 'button', {
56-
name: 'Select parent block: Cover',
57-
} )
58-
);
54+
await selectBlock( 'Block: Cover' );
5955
}
6056

6157
describe( 'Cover block', () => {

test/e2e/specs/editor/plugins/post-type-locking.spec.js

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ test.describe( 'Post-type locking', () => {
5050
name: 'Empty block',
5151
} )
5252
.first()
53-
.click();
53+
.fill( 'p1' );
54+
await editor.showBlockToolbar();
5455

5556
await expect(
5657
page
@@ -166,18 +167,15 @@ test.describe( 'Post-type locking', () => {
166167
).toBeHidden();
167168
} );
168169

169-
test( 'should allow blocks to be moved', async ( { editor, page } ) => {
170+
test( 'should allow blocks to be moved', async ( { editor } ) => {
170171
await editor.canvas
171172
.getByRole( 'document', {
172173
name: 'Empty block',
173174
} )
174175
.first()
175-
.click();
176+
.fill( 'p1' );
176177

177-
await page
178-
.getByRole( 'toolbar', { name: 'Block tools' } )
179-
.getByRole( 'button', { name: 'Move up' } )
180-
.click();
178+
await editor.clickBlockToolbarButton( 'Move up' );
181179

182180
await expect.poll( editor.getBlocks ).toMatchObject( [
183181
{
@@ -248,18 +246,15 @@ test.describe( 'Post-type locking', () => {
248246
] );
249247
} );
250248

251-
test( 'should allow blocks to be moved', async ( { editor, page } ) => {
249+
test( 'should allow blocks to be moved', async ( { editor } ) => {
252250
await editor.canvas
253251
.getByRole( 'document', {
254252
name: 'Empty block',
255253
} )
256254
.first()
257-
.click();
255+
.fill( 'p1' );
258256

259-
await page
260-
.getByRole( 'toolbar', { name: 'Block tools' } )
261-
.getByRole( 'button', { name: 'Move up' } )
262-
.click();
257+
await editor.clickBlockToolbarButton( 'Move up' );
263258

264259
await expect.poll( editor.getBlocks ).toMatchObject( [
265260
{
@@ -304,18 +299,15 @@ test.describe( 'Post-type locking', () => {
304299
] );
305300
} );
306301

307-
test( 'should allow blocks to be moved', async ( { editor, page } ) => {
302+
test( 'should allow blocks to be moved', async ( { editor } ) => {
308303
await editor.canvas
309304
.getByRole( 'document', {
310305
name: 'Empty block',
311306
} )
312307
.last()
313-
.click();
308+
.fill( 'p1' );
314309

315-
await page
316-
.getByRole( 'toolbar', { name: 'Block tools' } )
317-
.getByRole( 'button', { name: 'Move up' } )
318-
.click();
310+
await editor.clickBlockToolbarButton( 'Move up' );
319311

320312
await expect.poll( editor.getBlocks ).toMatchObject( [
321313
{
@@ -409,7 +401,8 @@ test.describe( 'Post-type locking', () => {
409401
name: 'Empty block',
410402
} )
411403
.last()
412-
.click();
404+
.fill( 'p1' );
405+
await editor.showBlockToolbar();
413406

414407
await expect(
415408
page
@@ -453,7 +446,8 @@ test.describe( 'Post-type locking', () => {
453446
name: 'Empty block',
454447
} )
455448
.last()
456-
.click();
449+
.fill( 'p1' );
450+
await editor.showBlockToolbar();
457451

458452
await expect(
459453
page

0 commit comments

Comments
 (0)