From 512ec24f0a5ea7d12408821d01700213c385278e Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Sat, 7 Dec 2024 14:09:20 +0900 Subject: [PATCH] Shadows: Improve design and a11y of remove button --- .../global-styles/shadows-edit-panel.js | 41 +++++++++---------- .../src/components/global-styles/style.scss | 40 ++++++++++++------ 2 files changed, 47 insertions(+), 34 deletions(-) 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 f26a8a5ed17436..0de1f2c99362ca 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 && ( - -