From 8d6f0b6d4a35bb5dc96ab7659857509f0f422635 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 8 Nov 2023 19:40:23 +0400 Subject: [PATCH] Block Support: Hide the background image reset button when there's no image --- packages/block-editor/src/hooks/background.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/block-editor/src/hooks/background.js b/packages/block-editor/src/hooks/background.js index f78341e16df8e0..9e9a3a27c1805e 100644 --- a/packages/block-editor/src/hooks/background.js +++ b/packages/block-editor/src/hooks/background.js @@ -241,10 +241,12 @@ function BackgroundImagePanelItem( props ) { }; }, [] ); + const hasValue = hasBackgroundImageValue( props ); + return ( hasBackgroundImageValue( props ) } + hasValue={ () => hasValue } label={ __( 'Background image' ) } onDeselect={ () => resetBackgroundImage( props ) } isShownByDefault={ true } @@ -267,9 +269,13 @@ function BackgroundImagePanelItem( props ) { } variant="secondary" > - resetBackgroundImage( props ) }> - { __( 'Reset ' ) } - + { hasValue && ( + resetBackgroundImage( props ) } + > + { __( 'Reset ' ) } + + ) }