Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@
az_remove_sidebar_menu_mobile ? 'd-none d-md-block'
]
%}
{% set base_navigation_label = configuration.label|default('Navigation'|t) %}
{% set navigation_context = attributes.id matches '/mobile|offcanvas/' ? 'Mobile'|t : ('Sidebar'|t) %}
{% set navigation_label = navigation_context ? navigation_context ~ ' ' ~ base_navigation_label : base_navigation_label %}
{% set heading_id = attributes.id ~ '-menu'|clean_id %}
<nav role="navigation" aria-labelledby="{{ heading_id }}"{{ attributes.addClass(classes)|without('role', 'aria-labelledby') }}>
<nav role="navigation" aria-label="{{ navigation_label }}"{{ attributes.addClass(classes)|without('role', 'aria-label') }}>
{# Label. If not displayed, we still provide it for screen readers. #}
{% if not configuration.label_display %}
{% set title_attributes = title_attributes.addClass('visually-hidden') %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@
'menu--' ~ derivative_plugin_id|clean_class,
]
%}
{% set base_navigation_label = configuration.label|default('Navigation'|t) %}
{% set navigation_context = attributes.id matches '/mobile|offcanvas/' ? 'Mobile'|t : '' %}
{% set navigation_label = navigation_context ? navigation_context ~ ' ' ~ base_navigation_label : base_navigation_label %}
{% set heading_id = attributes.id ~ '-menu'|clean_id %}
<nav role="navigation" aria-labelledby="{{ heading_id }}"{{ attributes.addClass(classes)|without('role', 'aria-labelledby') }}>
<nav role="navigation" aria-label="{{ navigation_label }}"{{ attributes.addClass(classes)|without('role', 'aria-label') }}>
{# Label. If not displayed, we still provide it for screen readers. #}
{% if not configuration.label_display %}
{% set title_attributes = title_attributes.addClass('visually-hidden') %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
{% set mobile_page_numbers_each_side_of_current = 1 %}
{% set mobile_total_page_numbers_to_show = 2 * mobile_page_numbers_each_side_of_current + 1 %}
{% if items %}
<nav role="navigation" aria-label="{{ heading_id }}">
<h3 id="{{ heading_id }}" class="visually-hidden">{{ 'Pagination'|t }}</h3>
<nav role="navigation" aria-labelledby="{{ heading_id }}">
<h2 id="{{ heading_id }}" class="visually-hidden">{{ 'Pagination'|t }}</h2>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@accesswatch could you explain the reason for the change in heading level?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure - two related problems. As an h3, the hidden Pagination heading implied a subsection of an h2 that doesn't exist on most pages that render pagers (search results and listing pages typically have the h1 page title and then h2 content sections), so it produced a skipped heading level that axe flags as heading-order and that makes the heading outline confusing when navigating by headings with a screen reader. Promoting it to h2 puts Pagination at the same outline level as the content sections it follows. The companion change from aria-label to aria-labelledby fixes the landmark name itself: aria-label="{{ heading_id }}" was announcing the raw machine ID as the navigation landmark's name, while aria-labelledby points at the heading so the landmark is announced with the translated 'Pagination' text.

<ul class="pagination js-pager__items">
{# Print first item if we are not on the first page. #}
{% if items.first %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/
#}
{% if items.previous or items.next %}
<nav role="navigation" aria-label="{{ heading_id }}">
<h3 id="{{ heading_id }}" class="visually-hidden">{{ 'Pagination'|t }}</h3>
<nav role="navigation" aria-labelledby="{{ heading_id }}">
<h2 id="{{ heading_id }}" class="visually-hidden">{{ 'Pagination'|t }}</h2>
<ul class="js-pager__items pagination">
{% if items.previous %}
<li class="page-item">
Expand Down
Loading