From cef484e5f6fa1a1ea408ed797d3ec3a474f63136 Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Wed, 22 May 2024 12:53:44 +0300 Subject: [PATCH] Zoom out: Render in-between inserters when selected (#61559) --- .../src/components/block-tools/zoom-out-mode-inserters.js | 4 +++- test/e2e/specs/site-editor/zoom-out.spec.js | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/block-tools/zoom-out-mode-inserters.js b/packages/block-editor/src/components/block-tools/zoom-out-mode-inserters.js index 4396f54b19707b..ca27fd8ad37857 100644 --- a/packages/block-editor/src/components/block-tools/zoom-out-mode-inserters.js +++ b/packages/block-editor/src/components/block-tools/zoom-out-mode-inserters.js @@ -21,6 +21,7 @@ function ZoomOutModeInserters() { sectionRootClientId, insertionPoint, setInserterIsOpened, + selectedSection, } = useSelect( ( select ) => { const { getSettings, getBlockOrder } = select( blockEditorStore ); const { sectionRootClientId: root } = unlock( getSettings() ); @@ -32,6 +33,7 @@ function ZoomOutModeInserters() { // eslint-disable-next-line @wordpress/data-no-store-string-literals const editor = select( 'core/editor' ); return { + selectedSection: editor.getSelectedBlock(), blockOrder: getBlockOrder( root ), insertionPoint: unlock( editor ).getInsertionPoint(), sectionRootClientId: root, @@ -62,7 +64,7 @@ function ZoomOutModeInserters() { }; }, [] ); - if ( ! isReady ) { + if ( ! isReady || ! selectedSection ) { return null; } diff --git a/test/e2e/specs/site-editor/zoom-out.spec.js b/test/e2e/specs/site-editor/zoom-out.spec.js index 63ad58b2e18a59..2cd0db8b1ebe22 100644 --- a/test/e2e/specs/site-editor/zoom-out.spec.js +++ b/test/e2e/specs/site-editor/zoom-out.spec.js @@ -24,6 +24,12 @@ test.describe( 'Zoom Out', () => { await page.getByRole( 'button', { name: 'Styles' } ).click(); await page.getByRole( 'button', { name: 'Browse styles' } ).click(); + // select the 1st pattern + await page + .frameLocator( 'iframe[name="editor-canvas"]' ) + .locator( 'header' ) + .click(); + await expect( page.getByLabel( 'Add pattern' ) ).toHaveCount( 3 ); await page.getByLabel( 'Add pattern' ).first().click(); await expect( page.getByLabel( 'Add pattern' ) ).toHaveCount( 2 );