diff --git a/packages/block-library/src/cover/edit/index.jsx b/packages/block-library/src/cover/edit/index.jsx
index e078f02bb6bb0e..fea7cda95e81fa 100644
--- a/packages/block-library/src/cover/edit/index.jsx
+++ b/packages/block-library/src/cover/edit/index.jsx
@@ -703,10 +703,13 @@ function CoverEdit( {
setOverlayColor={ onSetOverlayColor }
coverRef={ ref }
currentSettings={ currentSettings }
+ onSelectMedia={ onSelectMedia }
+ onUploadError={ onUploadError }
toggleUseFeaturedImage={ toggleUseFeaturedImage }
updateDimRatio={ onUpdateDimRatio }
onClearMedia={ onClearMedia }
featuredImage={ media }
+ isSelected={ isSelected }
/>
);
diff --git a/packages/block-library/src/cover/edit/inspector-controls.jsx b/packages/block-library/src/cover/edit/inspector-controls.jsx
index 059cbe3b1ec0ba..f01399603e52d9 100644
--- a/packages/block-library/src/cover/edit/inspector-controls.jsx
+++ b/packages/block-library/src/cover/edit/inspector-controls.jsx
@@ -23,8 +23,13 @@ import {
import { __ } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
+import { getFilename } from '@wordpress/url';
import { Link } from '@wordpress/ui';
-import { COVER_MIN_HEIGHT, mediaPosition } from '../shared';
+import {
+ ALLOWED_MEDIA_TYPES,
+ COVER_MIN_HEIGHT,
+ mediaPosition,
+} from '../shared';
import { unlock } from '../../lock-unlock';
import { useToolsPanelDropdownMenuProps } from '../../utils/hooks';
import {
@@ -35,6 +40,7 @@ import {
} from '../../utils/style-state';
import { DEFAULT_MEDIA_SIZE_SLUG } from '../constants';
import PosterImage from '../../utils/poster-image';
+import { MediaControl } from '../../utils/media-control';
const { cleanEmptyObject, ResolutionTool, HTMLElementControl } = unlock(
blockEditorPrivateApis
@@ -95,8 +101,13 @@ export default function CoverInspectorControls( {
setOverlayColor,
coverRef,
currentSettings,
+ onSelectMedia,
+ onUploadError,
+ toggleUseFeaturedImage,
updateDimRatio,
+ onClearMedia,
featuredImage,
+ isSelected,
} ) {
const {
useFeaturedImage,
@@ -138,6 +149,7 @@ export default function CoverInspectorControls( {
},
[ clientId ]
);
+
const selectedStyleStateKey = getStyleStateKey( selectedStyleState );
const stateMinHeight = getActiveDimensionValue( {
attributes,
@@ -275,8 +287,49 @@ export default function CoverInspectorControls( {
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
+ /*
+ * Rendered whether or not media has been set, so that a cover in its setup
+ * state can be given media from the inspector as well as from the toolbar.
+ * The settings below stay behind their own condition, having nothing to
+ * configure until there is media to configure.
+ */
+ const mediaInspectorPanel = isSelected ? (
+
+
+ !! url || !! useFeaturedImage }
+ onDeselect={ onClearMedia }
+ isShownByDefault
+ >
+
+
+
+
+ ) : null;
+
return (
<>
+ { mediaInspectorPanel }
{ ( !! url || useFeaturedImage ) && (
{
beforeEach( () => registerCoreBlocks() );
@@ -207,11 +217,12 @@ describe( 'Cover block', () => {
} )
).not.toBeInTheDocument();
} );
- test( 'does not display settings tab when media settings are empty', async () => {
+ test( 'does not display settings panel in the settings tab when the block has no media', async () => {
await createAndSelectBlock();
+ await openSettingsTabIfAvailable();
expect(
- screen.queryByRole( 'tab', {
+ screen.queryByRole( 'heading', {
name: 'Settings',
} )
).not.toBeInTheDocument();
@@ -227,6 +238,7 @@ describe( 'Cover block', () => {
} );
await selectBlock( 'Block: Cover' );
+ await openSettingsTabIfAvailable();
expect(
await screen.findByRole( 'heading', { name: 'Settings' } )
).toBeInTheDocument();
@@ -241,6 +253,7 @@ describe( 'Cover block', () => {
'has-parallax'
);
await selectBlock( 'Block: Cover' );
+ await openSettingsTabIfAvailable();
await userEvent.click(
await screen.findByLabelText( 'Fixed background' )
);
@@ -257,6 +270,7 @@ describe( 'Cover block', () => {
'is-repeated'
);
await selectBlock( 'Block: Cover' );
+ await openSettingsTabIfAvailable();
await userEvent.click(
await screen.findByLabelText( 'Repeated background' )
);
@@ -271,6 +285,7 @@ describe( 'Cover block', () => {
} );
await selectBlock( 'Block: Cover' );
+ await openSettingsTabIfAvailable();
await userEvent.clear( await screen.findByLabelText( 'Left' ) );
await userEvent.type( screen.getByLabelText( 'Left' ), '100' );
@@ -288,6 +303,7 @@ describe( 'Cover block', () => {
} );
await selectBlock( 'Block: Cover' );
+ await openSettingsTabIfAvailable();
await userEvent.type(
await screen.findByLabelText( 'Alternative text' ),
'Me'
diff --git a/test/e2e/specs/editor/blocks/cover.spec.js b/test/e2e/specs/editor/blocks/cover.spec.js
index c3b91e21030073..3a876c618fc72a 100644
--- a/test/e2e/specs/editor/blocks/cover.spec.js
+++ b/test/e2e/specs/editor/blocks/cover.spec.js
@@ -403,6 +403,9 @@ test.describe( 'Cover', () => {
await editor.selectBlocks( coverBlock );
+ // The focal point picker is in the Settings tab of the block inspector.
+ await page.getByRole( 'tab', { name: 'Settings' } ).click();
+
// The focal point picker renders as a `legend`-labelled group, so both
// spinbuttons are resolved through it.
const focalPointGroup = page.getByRole( 'group', {