From 59595f6d0f44d7cce27c20df8f8b58a72f021afa Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Tue, 17 Sep 2024 15:54:27 +0200 Subject: [PATCH] Fix the shadows Range control accessibility and usability (#63908) * Use real labels instaed of headings or aria-labels. * Simplify by removing RangeControl. * Remove unnecessary HStack and className. * Remove no longer used hasNegativeRange prop. Co-authored-by: afercia Co-authored-by: t-hamano Co-authored-by: jameskoster Co-authored-by: richtabor --- .../global-styles/shadows-edit-panel.js | 69 ++----------------- 1 file changed, 7 insertions(+), 62 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 cf49d8c28ebcb9..ec1dd1a900c3bf 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 @@ -13,7 +13,6 @@ import { __experimentalItemGroup as ItemGroup, __experimentalInputControl as InputControl, __experimentalUnitControl as UnitControl, - __experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue, __experimentalGrid as Grid, __experimentalDropdownContentWrapper as DropdownContentWrapper, __experimentalUseNavigator as useNavigator, @@ -21,7 +20,6 @@ import { __experimentalToggleGroupControlOption as ToggleGroupControlOption, __experimentalConfirmDialog as ConfirmDialog, Dropdown, - RangeControl, Button, Flex, FlexItem, @@ -35,7 +33,6 @@ import { plus, shadow as shadowIcon, reset, - settings, moreVertical, } from '@wordpress/icons'; import { useState, useMemo } from '@wordpress/element'; @@ -51,7 +48,6 @@ import { getShadowParts, shadowStringToObject, shadowObjectToString, - CUSTOM_VALUE_SETTINGS, } from './shadow-utils'; const { useGlobalSetting } = unlock( blockEditorPrivateApis ); @@ -464,13 +460,11 @@ function ShadowPopover( { shadowObj, onChange } ) { onShadowChange( 'x', value ) } /> onShadowChange( 'y', value ) } /> onShadowChange( 'spread', value ) } /> @@ -489,16 +482,7 @@ function ShadowPopover( { shadowObj, onChange } ) { ); } -function ShadowInputControl( { label, value, onChange, hasNegativeRange } ) { - const [ isCustomInput, setIsCustomInput ] = useState( false ); - const [ parsedQuantity, parsedUnit ] = - parseQuantityAndUnitFromRawValue( value ); - - const sliderOnChange = ( next ) => { - onChange( - next !== undefined ? [ next, parsedUnit || 'px' ].join( '' ) : '0px' - ); - }; +function ShadowInputControl( { label, value, onChange } ) { const onValueChange = ( next ) => { const isNumeric = next !== undefined && ! isNaN( parseFloat( next ) ); const nextValue = isNumeric ? next : '0px'; @@ -506,50 +490,11 @@ function ShadowInputControl( { label, value, onChange, hasNegativeRange } ) { }; return ( - - - { label } -