Skip to content

Commit 203610f

Browse files
Mamadukacbravobernal
authored andcommitted
Block Support: Hide the background image reset button when there's no image (#55973)
1 parent 2e5c177 commit 203610f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

packages/block-editor/src/hooks/background.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,12 @@ function BackgroundImagePanelItem( props ) {
241241
};
242242
}, [] );
243243

244+
const hasValue = hasBackgroundImageValue( props );
245+
244246
return (
245247
<ToolsPanelItem
246248
className="single-column"
247-
hasValue={ () => hasBackgroundImageValue( props ) }
249+
hasValue={ () => hasValue }
248250
label={ __( 'Background image' ) }
249251
onDeselect={ () => resetBackgroundImage( props ) }
250252
isShownByDefault={ true }
@@ -267,9 +269,13 @@ function BackgroundImagePanelItem( props ) {
267269
}
268270
variant="secondary"
269271
>
270-
<MenuItem onClick={ () => resetBackgroundImage( props ) }>
271-
{ __( 'Reset ' ) }
272-
</MenuItem>
272+
{ hasValue && (
273+
<MenuItem
274+
onClick={ () => resetBackgroundImage( props ) }
275+
>
276+
{ __( 'Reset ' ) }
277+
</MenuItem>
278+
) }
273279
</MediaReplaceFlow>
274280
<DropZone
275281
onFilesDrop={ onFilesDrop }

0 commit comments

Comments
 (0)