diff --git a/packages/edit-site/src/components/global-styles/shadows-edit-panel.js b/packages/edit-site/src/components/global-styles/shadows-edit-panel.js index f26a8a5ed1743..0de1f2c99362c 100644 --- a/packages/edit-site/src/components/global-styles/shadows-edit-panel.js +++ b/packages/edit-site/src/components/global-styles/shadows-edit-panel.js @@ -35,7 +35,7 @@ import { reset, moreVertical, } from '@wordpress/icons'; -import { useState, useMemo, useEffect } from '@wordpress/element'; +import { useState, useMemo, useEffect, useRef } from '@wordpress/element'; /** * Internal dependencies @@ -300,6 +300,7 @@ function ShadowsPreview( { shadow } ) { } function ShadowEditor( { shadow, onChange } ) { + const addShadowButtonRef = useRef(); const shadowParts = useMemo( () => getShadowParts( shadow ), [ shadow ] ); const onChangeShadowPart = ( index, part ) => { @@ -314,6 +315,7 @@ function ShadowEditor( { shadow, onChange } ) { const onRemoveShadowPart = ( index ) => { onChange( shadowParts.filter( ( p, i ) => i !== index ).join( ', ' ) ); + addShadowButtonRef.current.focus(); }; return ( @@ -334,6 +336,7 @@ function ShadowEditor( { shadow, onChange } ) { onClick={ () => { onAddShadowPart(); } } + ref={ addShadowButtonRef } /> @@ -393,28 +396,24 @@ function ShadowItem( { shadow, onChange, canRemove, onRemove } ) { }; return ( - - - - + <> + { canRemove && ( - -