fix(pagination): add sr-only span to preserve aria-current on mobile AT
When the mobile label is aria-hidden and the desktop button container is display:none (below sm:), mobile screen reader users had no aria-current indicator. Added a sr-only span with aria-current="page" that stays in the AT tree at all breakpoints regardless of CSS display state. On desktop the active page button also carries aria-current — both announce the same page information, which is acceptable. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit was merged in pull request #346.
This commit is contained in:
@@ -95,7 +95,7 @@ const pageWindow = $derived.by(() => {
|
||||
{/if}
|
||||
|
||||
<!-- Mobile: "Seite X von Y" label (hidden on sm: and above) -->
|
||||
<!-- aria-hidden: desktop numbered buttons carry the aria-current="page" role; this label is redundant on wide screens -->
|
||||
<!-- aria-hidden: decorative visual label; AT uses the sr-only span below for aria-current -->
|
||||
<span
|
||||
data-testid="pagination-page-label"
|
||||
aria-hidden="true"
|
||||
@@ -103,6 +103,12 @@ const pageWindow = $derived.by(() => {
|
||||
>
|
||||
{m.pagination_page_of({ page: page + 1, total: totalPages })}
|
||||
</span>
|
||||
<!-- Always in the AT tree: announces current page regardless of breakpoint.
|
||||
On mobile, the desktop button container is display:none so this is the only AT anchor.
|
||||
On desktop, the active page button also carries aria-current — both announce the same info. -->
|
||||
<span data-testid="pagination-current-page-sr" aria-current="page" class="sr-only">
|
||||
{m.pagination_page_of({ page: page + 1, total: totalPages })}
|
||||
</span>
|
||||
|
||||
<!-- Desktop: numbered page buttons (hidden below sm:) -->
|
||||
<div data-testid="pagination-pages" class="hidden items-center gap-1 sm:flex">
|
||||
|
||||
Reference in New Issue
Block a user