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

Background Image Support: Hide the background image reset button when there's no image #55973

Merged
merged 1 commit into from Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions packages/block-editor/src/hooks/background.js
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