@@ -540,13 +625,17 @@ const Example = ( { id, title, blocks, isSelected, onClick, content } ) => {
'is-disabled-example': !! disabledProps?.disabled,
} ) }
id={ id }
- aria-label={ sprintf(
- // translators: %s: Title of a block, e.g. Heading.
- __( 'Open %s styles in Styles panel' ),
- title
- ) }
+ aria-label={
+ !! onClick
+ ? sprintf(
+ // translators: %s: Title of a block, e.g. Heading.
+ __( 'Open %s styles in Styles panel' ),
+ title
+ )
+ : undefined
+ }
render={
}
- role="button"
+ role={ !! onClick ? 'button' : null }
onClick={ onClick }
{ ...disabledProps }
>
diff --git a/packages/edit-site/src/components/style-book/style.scss b/packages/edit-site/src/components/style-book/style.scss
index 773b4f10f581b..42ffca2af1ed1 100644
--- a/packages/edit-site/src/components/style-book/style.scss
+++ b/packages/edit-site/src/components/style-book/style.scss
@@ -12,6 +12,10 @@
}
.edit-site-style-book__iframe {
+ display: block;
+ height: 100%;
+ width: 100%;
+
&.is-button {
border-radius: $radius-large;
}
diff --git a/test/e2e/specs/site-editor/navigation.spec.js b/test/e2e/specs/site-editor/navigation.spec.js
index 1b92ef2e850e6..18eb6c9904b44 100644
--- a/test/e2e/specs/site-editor/navigation.spec.js
+++ b/test/e2e/specs/site-editor/navigation.spec.js
@@ -45,13 +45,6 @@ test.describe( 'Site editor navigation', () => {
page.getByRole( 'button', { name: 'Pages' } )
).toBeFocused();
- // Navigate to the Saved button first, as it precedes the editor iframe.
- await editorNavigationUtils.tabToLabel( 'Saved' );
- const savedButton = page.getByRole( 'button', {
- name: 'Saved',
- } );
- await expect( savedButton ).toBeFocused();
-
// Get the iframe when it has a role=button and Edit label.
const editorCanvasRegion = page.getByRole( 'region', {
name: 'Editor content',
@@ -60,6 +53,15 @@ test.describe( 'Site editor navigation', () => {
name: 'Edit',
} );
+ await expect( editorCanvasButton ).toBeVisible();
+
+ // Navigate to the Saved button first, as it precedes the editor iframe.
+ await editorNavigationUtils.tabToLabel( 'Saved' );
+ const savedButton = page.getByRole( 'button', {
+ name: 'Saved',
+ } );
+ await expect( savedButton ).toBeFocused();
+
// Test that there are no tab stops between the Saved button and the
// focusable iframe with role=button.
await pageUtils.pressKeys( 'Tab' );
diff --git a/test/e2e/specs/site-editor/style-book.spec.js b/test/e2e/specs/site-editor/style-book.spec.js
index 38030892826ec..350b192538506 100644
--- a/test/e2e/specs/site-editor/style-book.spec.js
+++ b/test/e2e/specs/site-editor/style-book.spec.js
@@ -189,6 +189,30 @@ test.describe( 'Style Book', () => {
} );
} );
+test.describe( 'Style Book for classic themes', () => {
+ test( 'Should show Style Book for a theme that supports it', async ( {
+ page,
+ admin,
+ requestUtils,
+ } ) => {
+ // Make sure a classic theme is active.
+ await requestUtils.activateTheme( 'twentytwentyone' );
+ // Go to site editor.
+ await admin.visitAdminPage( 'site-editor.php' );
+
+ // Open the Style Book.
+ await page.getByRole( 'button', { name: 'Styles' } ).click();
+
+ // Block examples should be visible.
+ const blockExamples = page
+ .frameLocator( '[name="style-book-canvas"]' )
+ .getByRole( 'grid', {
+ name: 'Examples of blocks',
+ } );
+ await expect( blockExamples ).toBeVisible();
+ } );
+} );
+
class StyleBook {
constructor( { page } ) {
this.page = page;