Skip to content

Commit

Permalink
Fix: Wrap link lists in <nav> for accessibility in listing blocks (Wo…
Browse files Browse the repository at this point in the history
  • Loading branch information
im3dabasia committed Nov 8, 2024
1 parent 88cf9bd commit 9263ea0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
8 changes: 5 additions & 3 deletions packages/block-library/src/categories/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,11 @@ export default function CategoriesEdit( {
) }
{ ! isResolving &&
categories?.length > 0 &&
( displayAsDropdown
? renderCategoryDropdown()
: renderCategoryList() ) }
( displayAsDropdown ? (
renderCategoryDropdown()
) : (
<nav>{ renderCategoryList() }</nav>
) ) }
</TagName>
);
}
2 changes: 1 addition & 1 deletion packages/block-library/src/categories/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function render_block_core_categories( $attributes, $content, $block ) {
} else {
$args['show_option_none'] = $taxonomy->labels->no_terms;

$wrapper_markup = '<ul %1$s>%2$s</ul>';
$wrapper_markup = '<nav><ul %1$s>%2$s</ul></nav>';
$items_markup = wp_list_categories( $args );
$type = 'list';

Expand Down
6 changes: 5 additions & 1 deletion packages/block-library/src/page-list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ function BlockContent( {
}

if ( pages.length > 0 ) {
return <ul { ...innerBlocksProps }></ul>;
return (
<nav>
<ul { ...innerBlocksProps }></ul>
</nav>
);
}
}

Expand Down
5 changes: 2 additions & 3 deletions packages/block-library/src/page-list/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,8 @@ function render_block_core_page_list( $attributes, $content, $block ) {
);

return sprintf(
$wrapper_markup,
$wrapper_attributes,
$items_markup
'<nav>%s</nav>',
sprintf( $wrapper_markup, $wrapper_attributes, $items_markup )
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/tag-cloud/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function render_block_core_tag_cloud( $attributes ) {
$wrapper_attributes = get_block_wrapper_attributes();

return sprintf(
'<p %1$s>%2$s</p>',
'<nav %1$s>%2$s</nav>',
$wrapper_attributes,
$tag_cloud
);
Expand Down

0 comments on commit 9263ea0

Please sign in to comment.