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

Show the inserters only when a section is selected #61559

Merged
merged 2 commits into from
May 22, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function ZoomOutModeInserters() {
sectionRootClientId,
insertionPoint,
setInserterIsOpened,
selectedSection,
} = useSelect( ( select ) => {
const { getSettings, getBlockOrder } = select( blockEditorStore );
const { sectionRootClientId: root } = unlock( getSettings() );
Expand All @@ -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,
Expand Down Expand Up @@ -62,7 +64,7 @@ function ZoomOutModeInserters() {
};
}, [] );

if ( ! isReady ) {
if ( ! isReady || ! selectedSection ) {
return null;
}

Expand Down
6 changes: 6 additions & 0 deletions test/e2e/specs/site-editor/zoom-out.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@
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();
Comment on lines +27 to +31
Copy link
Member

Choose a reason for hiding this comment

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

This probably should be a separate test.


await expect( page.getByLabel( 'Add pattern' ) ).toHaveCount( 3 );
await page.getByLabel( 'Add pattern' ).first().click();
await expect( page.getByLabel( 'Add pattern' ) ).toHaveCount( 2 );

Check failure on line 35 in test/e2e/specs/site-editor/zoom-out.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 6

[chromium] › site-editor/zoom-out.spec.js:20:2 › Zoom Out › Clicking on inserter while on zoom-out should open the patterns tab on the inserter

1) [chromium] › site-editor/zoom-out.spec.js:20:2 › Zoom Out › Clicking on inserter while on zoom-out should open the patterns tab on the inserter Error: Timed out 5000ms waiting for expect(locator).toHaveCount(expected) Locator: getByLabel('Add pattern') Expected: 2 Received: 0 Call log: - expect.toHaveCount with timeout 5000ms - waiting for getByLabel('Add pattern') - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" 33 | await expect( page.getByLabel( 'Add pattern' ) ).toHaveCount( 3 ); 34 | await page.getByLabel( 'Add pattern' ).first().click(); > 35 | await expect( page.getByLabel( 'Add pattern' ) ).toHaveCount( 2 ); | ^ 36 | 37 | await expect( 38 | page at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/zoom-out.spec.js:35:52

await expect(
page
Expand Down