Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 17 additions & 7 deletions packages/block-editor/src/components/list-view/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,20 @@ function ListViewBlock( {
level
);

const blockAriaLabel = isLocked
? sprintf(
// translators: %s: The title of the block. This string indicates a link to select the locked block.
__( '%s (locked)' ),
blockTitle
)
: blockTitle;
let blockAriaLabel = __( 'Link' );
if ( blockInformation ) {
blockAriaLabel = isLocked
? sprintf(
// translators: %s: The title of the block. This string indicates a link to select the locked block.
__( '%s link (locked)' ),
blockInformation.title
)
: sprintf(
// translators: %s: The title of the block. This string indicates a link to select the block.
__( '%s link' ),
blockInformation.title
);
}

const settingsAriaLabel = sprintf(
// translators: %s: The title of the block.
Expand Down Expand Up @@ -246,7 +253,10 @@ function ListViewBlock( {
className="block-editor-list-view-block__contents-cell"
colSpan={ colSpan }
ref={ cellRef }
aria-label={ blockAriaLabel }
aria-selected={ !! isSelected || forceSelectionContentLock }
aria-expanded={ isContentLocked ? undefined : isExpanded }
aria-describedby={ descriptionId }
>
{ ( { ref, tabIndex, onFocus } ) => (
<div className="block-editor-list-view-block__contents-container">
Expand Down
30 changes: 15 additions & 15 deletions test/e2e/specs/editor/various/list-view.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test.describe( 'List View', () => {
// The last inserted block should be selected.
await expect(
listView.getByRole( 'gridcell', {
name: 'Paragraph',
name: 'Paragraph link',
exact: true,
selected: true,
} )
Expand All @@ -44,11 +44,11 @@ test.describe( 'List View', () => {

// Drag the paragraph above the heading.
const paragraphBlockItem = listView.getByRole( 'gridcell', {
name: 'Paragraph',
name: 'Paragraph link',
exact: true,
} );
const headingBlockItem = listView.getByRole( 'gridcell', {
name: 'Heading',
name: 'Heading link',
exact: true,
} );
await paragraphBlockItem.dragTo( headingBlockItem, { x: 0, y: 0 } );
Expand Down Expand Up @@ -83,7 +83,7 @@ test.describe( 'List View', () => {
// The last inserted block should be selected.
await expect(
listView.getByRole( 'gridcell', {
name: 'Paragraph',
name: 'Paragraph link',
exact: true,
selected: true,
} )
Expand Down Expand Up @@ -135,7 +135,7 @@ test.describe( 'List View', () => {
// The last inserted block should be selected.
await expect(
listView.getByRole( 'gridcell', {
name: 'Paragraph',
name: 'Paragraph link',
exact: true,
selected: true,
} )
Expand Down Expand Up @@ -175,7 +175,7 @@ test.describe( 'List View', () => {
// The last inserted block should be selected.
await expect(
listView.getByRole( 'gridcell', {
name: 'Paragraph',
name: 'Paragraph link',
exact: true,
selected: true,
} )
Expand Down Expand Up @@ -227,7 +227,7 @@ test.describe( 'List View', () => {
// The last inserted block should be selected.
await expect(
listView.getByRole( 'gridcell', {
name: 'Heading',
name: 'Heading link',
exact: true,
selected: true,
} )
Expand All @@ -237,7 +237,7 @@ test.describe( 'List View', () => {
await pageUtils.pressKeys( 'shift+ArrowUp' );
await expect(
listView.getByRole( 'gridcell', {
name: 'Image',
name: 'Image link',
exact: true,
selected: true,
} )
Expand Down Expand Up @@ -287,15 +287,15 @@ test.describe( 'List View', () => {
// The child paragraph block should be selected.
await expect(
listView.getByRole( 'gridcell', {
name: 'Paragraph',
name: 'Paragraph link',
exact: true,
selected: true,
} )
).toBeVisible();

// Collapse the Cover block.
await listView
.getByRole( 'gridcell', { name: 'Cover', exact: true } )
.getByRole( 'gridcell', { name: 'Cover link', exact: true } )
.getByTestId( 'list-view-expander', { includeHidden: true } )
// Force the click to bypass the visibility check. The expander is
// intentionally aria-hidden. See the implementation for details.
Expand All @@ -321,7 +321,7 @@ test.describe( 'List View', () => {
// The child paragraph block in List View should be selected.
await expect(
listView.getByRole( 'gridcell', {
name: 'Paragraph',
name: 'Paragraph link',
exact: true,
selected: true,
} )
Expand Down Expand Up @@ -349,7 +349,7 @@ test.describe( 'List View', () => {
// The last inserted block should be selected.
await expect(
listView.getByRole( 'gridcell', {
name: 'Group',
name: 'Group link',
exact: true,
selected: true,
} )
Expand All @@ -368,7 +368,7 @@ test.describe( 'List View', () => {
await page.keyboard.press( 'ArrowUp' );
await expect(
listView.getByRole( 'link', {
name: 'Columns',
name: 'Columns link',
exact: true,
} )
).toBeFocused();
Expand Down Expand Up @@ -415,7 +415,7 @@ test.describe( 'List View', () => {
// The paragraph item should be selected.
await expect(
listView.getByRole( 'gridcell', {
name: 'Paragraph',
name: 'Paragraph link',
exact: true,
selected: true,
} )
Expand Down Expand Up @@ -526,7 +526,7 @@ test.describe( 'List View', () => {
// The last inserted block should be selected.
await expect(
listView.getByRole( 'gridcell', {
name: 'Paragraph',
name: 'Paragraph link',
exact: true,
selected: true,
} )
Expand Down