Skip to content

Commit

Permalink
fix: Update alignment control labels and remove default description f…
Browse files Browse the repository at this point in the history
…or clear labels
  • Loading branch information
dhananjaykuber committed Jan 6, 2025
1 parent 983b9a3 commit f0fbfa9
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 27 deletions.
8 changes: 3 additions & 5 deletions packages/block-editor/src/components/alignment-control/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ function AlignmentUI( {
value,
onChange,
alignmentControls = DEFAULT_ALIGNMENT_CONTROLS,
label = __( 'Align text' ),
description = __( 'Change text alignment' ),
label = __( 'Align block' ),
description,
isCollapsed = true,
isToolbar,
} ) {
Expand All @@ -55,9 +55,7 @@ function AlignmentUI( {
const extraProps = isToolbar
? { isCollapsed }
: {
toggleProps: {
description,
},
toggleProps: description ? { description } : {},
popoverProps: POPOVER_PROPS,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function BlockAlignmentUI( {
isToolbar,
isCollapsed = true,
label = __( 'Align block' ),
description = __( 'Change block alignment' ),
description,
} ) {
const enabledControls = useAvailableAlignments( controls );
const hasEnabledControls = !! enabledControls.length;
Expand Down Expand Up @@ -66,7 +66,9 @@ function BlockAlignmentUI( {
} ),
}
: {
toggleProps: { 'aria-description': description },
toggleProps: description
? { 'aria-description': description }
: {},
children: ( { onClose } ) => {
return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`BlockVerticalAlignmentUI should match snapshot when controls are hidden
<button
aria-expanded="false"
aria-haspopup="true"
aria-label="Align vertically"
aria-label="Align content vertically"
class="components-button components-dropdown-menu__toggle has-icon"
data-toolbar-item="true"
type="button"
Expand All @@ -36,7 +36,7 @@ exports[`BlockVerticalAlignmentUI should match snapshot when controls are visibl
<div
class="components-toolbar"
icon="[object Object]"
label="Align vertically"
label="Align content vertically"
>
<div>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe( 'BlockVerticalAlignmentUI', () => {

await user.click(
screen.getByRole( 'button', {
name: 'Align vertically',
name: 'Align content vertically',
} )
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ function BlockVerticalAlignmentUI( {
controls = DEFAULT_CONTROLS,
isCollapsed = true,
isToolbar,
label = _x( 'Align vertically', 'Block vertical alignment setting label' ),
description = _x(
'Change vertical alignment',
'Block vertical alignment setting description'
label = _x(
'Align content vertically',
'Block vertical alignment setting label'
),
description,
} ) {
function applyOrUnset( align ) {
return () => onChange( value === align ? undefined : align );
Expand All @@ -62,9 +62,11 @@ function BlockVerticalAlignmentUI( {
? { isCollapsed }
: {
popoverProps: { focusOnMount: 'firstElement' },
toggleProps: {
describedBy: description,
},
toggleProps: description
? {
describedBy: description,
}
: {},
};

const commonProps = {
Expand Down
4 changes: 1 addition & 3 deletions packages/block-library/src/media-text/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,7 @@ function MediaTextEdit( {
<BlockVerticalAlignmentControl
onChange={ onVerticalAlignmentChange }
value={ verticalAlignment }
description={ __(
'Adjust the vertical alignment of content within the block'
) }
label={ __( 'Align media and text vertically' ) }
/>
<ToolbarButton
icon={ pullLeft }
Expand Down
4 changes: 1 addition & 3 deletions packages/block-library/src/paragraph/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ function ParagraphBlock( {
: dropCap,
} )
}
description={ __(
'Adjust the alignment of text within the paragraph'
) }
label={ __( 'Align text' ) }
/>
<ParagraphRTLControl
direction={ direction }
Expand Down
5 changes: 1 addition & 4 deletions packages/block-library/src/table/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,7 @@ function TableEdit( {
<>
<BlockControls group="block">
<AlignmentControl
label={ __( 'Change column alignment' ) }
description={ __(
'Adjust the alignment of content within table columns'
) }
label={ __( 'Align columns content' ) }
alignmentControls={ ALIGNMENT_CONTROLS }
value={ getCellAlignment() }
onChange={ ( nextAlign ) =>
Expand Down

0 comments on commit f0fbfa9

Please sign in to comment.