From 34c172e35cdf0fc15b9d761e92e5bad382f5229e Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Mon, 29 May 2023 12:41:09 +1000 Subject: [PATCH] Fix labelling for all or fudged sides --- .../src/components/spacing-sizes-control/index.js | 10 ++++++++-- .../spacing-sizes-control/input-controls/single.js | 2 ++ .../input-controls/spacing-input-control.js | 12 +++++++++--- packages/block-library/src/spacer/controls.js | 1 + 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/block-editor/src/components/spacing-sizes-control/index.js b/packages/block-editor/src/components/spacing-sizes-control/index.js index f3db3340f4e975..5c26305331dd2d 100644 --- a/packages/block-editor/src/components/spacing-sizes-control/index.js +++ b/packages/block-editor/src/components/spacing-sizes-control/index.js @@ -71,7 +71,13 @@ export default function SpacingSizesControl( { if ( view === VIEWS.custom ) { return ; } - return ; + return ( + + ); }; const sideLabel = @@ -82,7 +88,7 @@ export default function SpacingSizesControl( { __( '%1$s %2$s' ), labelProp, sideLabel - ); + ).trim(); const dropdownLabelText = sprintf( // translators: %s: The current spacing property e.g. "Padding", "Margin". diff --git a/packages/block-editor/src/components/spacing-sizes-control/input-controls/single.js b/packages/block-editor/src/components/spacing-sizes-control/input-controls/single.js index 3537b62c335e8b..2bb0a409da0dd2 100644 --- a/packages/block-editor/src/components/spacing-sizes-control/input-controls/single.js +++ b/packages/block-editor/src/components/spacing-sizes-control/input-controls/single.js @@ -9,6 +9,7 @@ export default function SingleInputControl( { onChange, onMouseOut, onMouseOver, + showSideInLabel, side, spacingSizes, type, @@ -28,6 +29,7 @@ export default function SingleInputControl( { onChange={ createHandleOnChange( side ) } onMouseOut={ onMouseOut } onMouseOver={ onMouseOver } + showSideInLabel={ showSideInLabel } side={ side } spacingSizes={ spacingSizes } type={ type } diff --git a/packages/block-editor/src/components/spacing-sizes-control/input-controls/spacing-input-control.js b/packages/block-editor/src/components/spacing-sizes-control/input-controls/spacing-input-control.js index 0675f05554b385..f423596daaa4a5 100644 --- a/packages/block-editor/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +++ b/packages/block-editor/src/components/spacing-sizes-control/input-controls/spacing-input-control.js @@ -23,6 +23,7 @@ import { settings } from '@wordpress/icons'; import useSetting from '../../use-setting'; import { store as blockEditorStore } from '../../../store'; import { + ALL_SIDES, LABELS, getSliderValueFromPreset, getCustomValueFromPreset, @@ -46,6 +47,7 @@ export default function SpacingInputControl( { onChange, onMouseOut, onMouseOver, + showSideInLabel = true, side, spacingSizes, type, @@ -165,12 +167,16 @@ export default function SpacingInputControl( { label: undefined, } ) ); + const sideLabel = + ALL_SIDES.includes( side ) && showSideInLabel ? LABELS[ side ] : ''; + const typeLabel = showSideInLabel ? type?.toLowerCase() : type; + const ariaLabel = sprintf( // translators: 1: The side of the block being modified (top, bottom, left, All sides etc.). 2. Type of spacing being modified (Padding, margin, etc) __( '%1$s %2$s' ), - LABELS[ side ], - type?.toLowerCase() - ); + sideLabel, + typeLabel + ).trim(); return ( diff --git a/packages/block-library/src/spacer/controls.js b/packages/block-library/src/spacer/controls.js index ee702c42667819..d999550f16f331 100644 --- a/packages/block-library/src/spacer/controls.js +++ b/packages/block-library/src/spacer/controls.js @@ -81,6 +81,7 @@ function DimensionInput( { label, onChange, isResizing, value = '' } ) { units={ units } allowReset={ false } splitOnAxis={ false } + showSideInLabel={ false } /> ) }