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

[Block Library - Post Featured Image]: Show all the controls when inside a Query Loop #37945

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 29 additions & 19 deletions packages/block-library/src/post-featured-image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,36 @@ function PostFeaturedImageDisplay( {
createErrorNotice( message[ 2 ], { type: 'snackbar' } );
};

const controls = (
<>
<DimensionControls
clientId={ clientId }
attributes={ attributes }
setAttributes={ setAttributes }
/>
<InspectorControls>
<PanelBody title={ __( 'Link settings' ) }>
<ToggleControl
label={ sprintf(
// translators: %s: Name of the post type e.g: "post".
__( 'Link to %s' ),
postType
) }
onChange={ () => setAttributes( { isLink: ! isLink } ) }
checked={ isLink }
/>
</PanelBody>
</InspectorControls>
</>
);
let image;
if ( ! featuredImage && isDescendentOfQueryLoop ) {
return <div { ...blockProps }>{ placeholderChip }</div>;
return (
<>
{ controls }
<div { ...blockProps }>{ placeholderChip }</div>
</>
);
}

const label = __( 'Add a featured image' );
Expand Down Expand Up @@ -138,24 +165,7 @@ function PostFeaturedImageDisplay( {

return (
<>
<DimensionControls
clientId={ clientId }
attributes={ attributes }
setAttributes={ setAttributes }
/>
<InspectorControls>
<PanelBody title={ __( 'Link settings' ) }>
<ToggleControl
label={ sprintf(
// translators: %s: Name of the post type e.g: "post".
__( 'Link to %s' ),
postType
) }
onChange={ () => setAttributes( { isLink: ! isLink } ) }
checked={ isLink }
/>
</PanelBody>
</InspectorControls>
{ controls }
{ !! media && ! isDescendentOfQueryLoop && (
<BlockControls group="other">
<MediaReplaceFlow
Expand Down