Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
28cebc7
add label and description props and update default label of block ali…
dhananjaykuber Jul 18, 2024
17092f6
add label and description props to block vertical alignment control
dhananjaykuber Jul 18, 2024
1012f8e
update aria-description of media, paragraph and table block
dhananjaykuber Jul 18, 2024
ce55573
pass described by prop correctly
dhananjaykuber Jul 18, 2024
f6ad46c
update test cases
dhananjaykuber Jul 18, 2024
e348b27
update unit test for mobile
dhananjaykuber Jul 18, 2024
6139887
fix: Update alignment control labels and remove default description f…
dhananjaykuber Jan 6, 2025
50c28ed
Merge remote-tracking branch 'origin/trunk' into fix/improve-align-co…
t-hamano May 31, 2026
3f9a566
Block Vertical Alignment: Revert commonProps refactor
t-hamano May 31, 2026
c7989c8
Alignment Control: Use 'Align text' as the default label
t-hamano May 31, 2026
a7b3a94
Block Alignment Control: Use Button's 'description' prop
t-hamano May 31, 2026
e087b70
Block Vertical Alignment: Drop redundant translation context
t-hamano May 31, 2026
6cadd7e
Block Vertical Alignment: Drop unused description prop support
t-hamano May 31, 2026
c1ff9ec
Tests: Update alignment control labels in E2E and native tests
t-hamano May 31, 2026
0f2c2dc
Tests: Reformat alignment label test lines
t-hamano May 31, 2026
ef00534
Tests: Match Lock toolbar button exactly in block-locking E2E
t-hamano Jun 1, 2026
6cb6e26
Merge remote-tracking branch 'origin/trunk' into fix/improve-align-co…
t-hamano Jun 10, 2026
6c18913
Merge branch 'trunk' into fix/improve-align-controls-props-handling
t-hamano Jun 24, 2026
296c791
Merge branch 'trunk' into fix/improve-align-controls-props-handling
t-hamano Jul 8, 2026
7043347
Merge branch 'trunk' into fix/improve-align-controls-props-handling
t-hamano Jul 14, 2026
bc3bea8
Merge branch 'trunk' into fix/improve-align-controls-props-handling
t-hamano Jul 22, 2026
d9b6fb8
Table: Use singular 'Align column content' toolbar label
t-hamano Jul 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function AlignmentUI( {
onChange,
alignmentControls = DEFAULT_ALIGNMENT_CONTROLS,
label = __( 'Align text' ),
description = __( 'Change text alignment' ),
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 @@ -9,7 +9,7 @@ exports[`BlockAlignmentUI should match snapshot when controls are hidden 1`] = `
<button
aria-expanded="false"
aria-haspopup="true"
aria-label="Align"
aria-label="Align block"
class="components-button components-dropdown-menu__toggle has-icon"
data-toolbar-item="true"
type="button"
Expand Down Expand Up @@ -37,7 +37,7 @@ exports[`BlockAlignmentUI should match snapshot when controls are visible 1`] =
<div
class="components-toolbar"
icon="[object Object]"
label="Align"
label="Align block"
>
<div>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe( 'BlockAlignmentUI', () => {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function BlockAlignmentUI( {
controls,
isToolbar,
isCollapsed = true,
label = __( 'Align block' ),
description,
} ) {
const enabledControls = useAvailableAlignments( controls );
const hasEnabledControls = !! enabledControls.length;
Expand All @@ -47,7 +49,7 @@ function BlockAlignmentUI( {
icon: activeAlignmentControl
? activeAlignmentControl.icon
: defaultAlignmentControl.icon,
label: __( 'Align' ),
label,
};
const extraProps = isToolbar
? {
Expand All @@ -64,7 +66,7 @@ function BlockAlignmentUI( {
} ),
}
: {
toggleProps: { description: __( 'Change alignment' ) },
toggleProps: 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="Change vertical alignment"
aria-label="Align content vertically"
class="components-button components-dropdown-menu__toggle has-icon"
data-toolbar-item="true"
type="button"
Expand Down Expand Up @@ -37,7 +37,7 @@ exports[`BlockVerticalAlignmentUI should match snapshot when controls are visibl
<div
class="components-toolbar"
icon="[object Object]"
label="Change vertical alignment"
label="Align content vertically"
>
<div>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ describe( 'BlockVerticalAlignmentUI', () => {
expect( container ).toMatchSnapshot();
} );

test( 'should use custom label and description', () => {
render(
<BlockVerticalAlignmentUI
value={ alignment }
onChange={ onChange }
label="Custom Label"
description="Custom Description"
/>
);

const button = screen.getByRole( 'button', { name: 'Custom Label' } );
expect( button ).toHaveAttribute( 'aria-label', 'Custom Label' );
// The description is now part of the toggleProps and not directly accessible
// We can't easily test for the describedBy attribute here
} );

test( 'should expand controls when toggled', async () => {
const user = userEvent.setup();

Expand All @@ -59,7 +75,7 @@ describe( 'BlockVerticalAlignmentUI', () => {

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

Expand All @@ -86,7 +102,7 @@ describe( 'BlockVerticalAlignmentUI', () => {
);

const activeControl = screen.getByRole( 'button', {
name: `Align ${ alignment }`,
name: `Align top`,
pressed: true,
} );

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { _x } from '@wordpress/i18n';
import { __, _x } from '@wordpress/i18n';
import { ToolbarGroup, ToolbarDropdownMenu } from '@wordpress/components';
import {
justifyTop,
Expand Down Expand Up @@ -43,6 +43,7 @@ function BlockVerticalAlignmentUI( {
controls = DEFAULT_CONTROLS,
isCollapsed = true,
isToolbar,
label = __( 'Align content vertically' ),
} ) {
function applyOrUnset( align ) {
return () => onChange( value === align ? undefined : align );
Expand All @@ -62,10 +63,7 @@ function BlockVerticalAlignmentUI( {
? activeAlignment.icon
: defaultAlignmentControl.icon
}
label={ _x(
'Change vertical alignment',
'Block vertical alignment setting label'
) }
label={ label }
controls={ controls.map( ( control ) => {
return {
...BLOCK_ALIGNMENTS_CONTROLS[ control ],
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/media-text/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ function MediaTextEdit( {
<BlockVerticalAlignmentControl
onChange={ onVerticalAlignmentChange }
value={ verticalAlignment }
label={ __( 'Align media and text vertically' ) }
/>
<ToolbarButton
icon={ pullLeft }
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/table/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ function TableEdit( {
<>
<BlockControls group="block">
<AlignmentControl
label={ __( 'Change column alignment' ) }
label={ __( 'Align column content' ) }
alignmentControls={ ALIGNMENT_CONTROLS }
value={ getCellAlignment() }
onChange={ ( nextAlign ) =>
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/specs/editor/blocks/table.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,19 +208,19 @@ test.describe( 'Table', () => {
// Click to the next cell and add some text. Align left.
await cells.nth( 1 ).click();
await page.keyboard.type( 'To the left' );
await editor.clickBlockToolbarButton( 'Change column alignment' );
await editor.clickBlockToolbarButton( 'Align column content' );
await page.click( 'role=menuitemradio[name="Align column left"i]' );

// Click the next cell and add some text. Align center.
await cells.nth( 2 ).click();
await page.keyboard.type( 'Centered' );
await editor.clickBlockToolbarButton( 'Change column alignment' );
await editor.clickBlockToolbarButton( 'Align column content' );
await page.click( 'role=menuitemradio[name="Align column center"i]' );

// Tab to the next cell and add some text. Align right.
await cells.nth( 3 ).click();
await page.keyboard.type( 'Right aligned' );
await editor.clickBlockToolbarButton( 'Change column alignment' );
await editor.clickBlockToolbarButton( 'Align column content' );
await page.click( 'role=menuitemradio[name="Align column right"i]' );

// Expect the post to have the correct alignment classes inside the table.
Expand Down
Loading
Loading