Skip to content

Commit

Permalink
List view: add "position" information to the block accessible descrip…
Browse files Browse the repository at this point in the history
…tion text
  • Loading branch information
ciampo committed Jul 23, 2024
1 parent b737d32 commit 29bee42
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
13 changes: 10 additions & 3 deletions packages/block-editor/src/components/list-view/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,10 @@ function ListViewBlock( {
level
);

const blockPropertiesDescription =
getBlockPropertiesDescription( isLocked );
const blockPropertiesDescription = getBlockPropertiesDescription(
blockInformation,
isLocked
);

const hasSiblings = siblingBlockCount > 0;
const hasRenderedMovers = showBlockMovers && hasSiblings;
Expand Down Expand Up @@ -562,7 +564,12 @@ function ListViewBlock( {
ariaDescribedBy={ descriptionId }
/>
<AriaReferencedText id={ descriptionId }>
{ `${ blockPositionDescription } ${ blockPropertiesDescription }` }
{ [
blockPositionDescription,
blockPropertiesDescription,
]
.filter( Boolean )
.join( ' ' ) }
</AriaReferencedText>
</div>
) }
Expand Down
15 changes: 13 additions & 2 deletions packages/block-editor/src/components/list-view/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,19 @@ export const getBlockPositionDescription = ( position, siblingCount, level ) =>
level
);

export const getBlockPropertiesDescription = ( isLocked ) =>
isLocked ? __( 'This block is locked.' ) : '';
export const getBlockPropertiesDescription = ( blockInformation, isLocked ) =>
[
blockInformation?.positionLabel
? `${ sprintf(
// translators: 1: Position of selected block, e.g. "Sticky" or "Fixed".
__( 'Position: %1$s' ),
blockInformation.positionLabel
) }.`
: undefined,
isLocked ? __( 'This block is locked.' ) : undefined,
]
.filter( Boolean )
.join( ' ' );

/**
* Returns true if the client ID occurs within the block selection or multi-selection,
Expand Down

0 comments on commit 29bee42

Please sign in to comment.