From 4f1fd81ece72efc7d4b07661ec973e37a5b95fee Mon Sep 17 00:00:00 2001 From: ramonjd Date: Wed, 9 Nov 2022 08:21:30 +1100 Subject: [PATCH] Reinstating `useEffect` so that we can react to changes in the style state. --- .../block-library/src/group/placeholder.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/group/placeholder.js b/packages/block-library/src/group/placeholder.js index 5932df60a0b6a..0f8fbc253c898 100644 --- a/packages/block-library/src/group/placeholder.js +++ b/packages/block-library/src/group/placeholder.js @@ -6,7 +6,7 @@ import { useBlockProps } from '@wordpress/block-editor'; import { __ } from '@wordpress/i18n'; import { store as blocksStore } from '@wordpress/blocks'; import { Path, SVG, Button, Placeholder } from '@wordpress/components'; -import { useState } from '@wordpress/element'; +import { useState, useEffect } from '@wordpress/element'; /** * Returns a custom variation icon. @@ -97,6 +97,26 @@ export function useShouldShowPlaceHolder( { usedLayoutType !== 'flex' ); + useEffect( () => { + if ( + !! hasInnerBlocks || + !! backgroundColor || + !! fontSize || + !! textColor || + !! style || + usedLayoutType === 'flex' + ) { + setShowPlaceholder( false ); + } + }, [ + backgroundColor, + fontSize, + textColor, + style, + usedLayoutType, + hasInnerBlocks, + ] ); + return [ showPlaceholder, setShowPlaceholder ]; }