File tree Expand file tree Collapse file tree
src/resources/projects/website/listing
integration/playwright/tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -177,9 +177,13 @@ function decoratePagination(listingId) {
177177 itemEl . setAttribute ( "aria-hidden" , "true" ) ;
178178 continue ;
179179 }
180+ const pageNumber = linkEl . getAttribute ( "data-i" ) ;
181+ // A translation may drop the placeholder; keep the number in the name.
180182 linkEl . setAttribute (
181183 "aria-label" ,
182- pageLabel . replace ( "{0}" , linkEl . getAttribute ( "data-i" ) )
184+ pageLabel . includes ( "{0}" )
185+ ? pageLabel . replace ( "{0}" , pageNumber )
186+ : `${ pageLabel } ${ pageNumber } `
183187 ) ;
184188 if ( itemEl . classList . contains ( "active" ) ) {
185189 linkEl . setAttribute ( "aria-current" , "page" ) ;
Original file line number Diff line number Diff line change 1+ ---
2+ title : Label Override Test
3+ language :
4+ listing-page-number : " Page"
5+ listing :
6+ - id : override
7+ contents : posts
8+ type : default
9+ page-size : 1
10+ sort : title
11+ ---
12+
13+ ## Posts
14+
15+ ::: {#override}
16+ :::
Original file line number Diff line number Diff line change 11import { expect , Page , test } from "@playwright/test" ;
22
33const fixture = "./listings/pagination/_site/index.html" ;
4+ const overrideFixture = "./listings/pagination/_site/override.html" ;
45const singleFixture = "./listings/pagination/_site/single.html" ;
56
67// Link texts of each listing; the active page is wrapped in brackets.
@@ -188,6 +189,15 @@ test.describe("Listing pagination accessibility", () => {
188189 ) . toHaveAttribute ( "aria-current" , "page" ) ;
189190 } ) ;
190191
192+ test ( "a page label without {0} still ends with the page number" , async ( { page } ) => {
193+ await page . goto ( overrideFixture ) ;
194+ await expect ( nav ( page , "override" ) . locator ( "li.active" ) ) . toBeVisible ( ) ;
195+ const links = nav ( page , "override" ) . getByRole ( "link" ) ;
196+ await expect ( links . first ( ) ) . toHaveAccessibleName ( "Page 1" ) ;
197+ await expect ( links . nth ( 1 ) ) . toHaveAccessibleName ( "Page 2" ) ;
198+ await expect ( links . nth ( 2 ) ) . toHaveAccessibleName ( "Page 3" ) ;
199+ } ) ;
200+
191201 // With five listings on one page, every nav shares one label, so axe reports
192202 // landmark-unique. The single-listing page below checks that rule too.
193203 // region: the skip link sits outside any landmark, which has nothing to do
You can’t perform that action at this time.
0 commit comments