Skip to content

Commit

Permalink
[Block Library - Post Featured Image]: Show all the controls when ins…
Browse files Browse the repository at this point in the history
…ide a Query Loop (#37945)
  • Loading branch information
ntsekouras committed Jan 13, 2022
1 parent 22111f5 commit 5e4f87b
Showing 1 changed file with 29 additions and 19 deletions.
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

0 comments on commit 5e4f87b

Please sign in to comment.