Skip to content

Commit

Permalink
Block Support: Hide the background image reset button when there's no…
Browse files Browse the repository at this point in the history
… image (#55973)
  • Loading branch information
Mamaduka authored Nov 8, 2023
1 parent dded3a7 commit 8c0e893
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/block-editor/src/hooks/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,12 @@ function BackgroundImagePanelItem( props ) {
};
}, [] );

const hasValue = hasBackgroundImageValue( props );

return (
<ToolsPanelItem
className="single-column"
hasValue={ () => hasBackgroundImageValue( props ) }
hasValue={ () => hasValue }
label={ __( 'Background image' ) }
onDeselect={ () => resetBackgroundImage( props ) }
isShownByDefault={ true }
Expand All @@ -267,9 +269,13 @@ function BackgroundImagePanelItem( props ) {
}
variant="secondary"
>
<MenuItem onClick={ () => resetBackgroundImage( props ) }>
{ __( 'Reset ' ) }
</MenuItem>
{ hasValue && (
<MenuItem
onClick={ () => resetBackgroundImage( props ) }
>
{ __( 'Reset ' ) }
</MenuItem>
) }
</MediaReplaceFlow>
<DropZone
onFilesDrop={ onFilesDrop }
Expand Down

0 comments on commit 8c0e893

Please sign in to comment.