Skip to content

Commit f224787

Browse files
authored
A11y: Add focus state to pagination current page (#52237)
1 parent 051d49a commit f224787

File tree

2 files changed

+33
-23
lines changed

2 files changed

+33
-23
lines changed

src/search/components/SearchResults.module.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,11 @@
66

77
word-wrap: break-word;
88
}
9+
10+
.paginationFocus
11+
a[aria-current]:not([rel]):not(:disabled):not(:focus-visible):focus,
12+
.paginationFocus a[aria-current]:not([rel]):not(:disabled):focus-visible {
13+
outline: 2px solid var(--fgColor-accent, var(--color-accent-fg));
14+
outline-offset: -2px;
15+
box-shadow: 0 0 0 4px inset;
16+
}

src/search/components/SearchResults.tsx

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -143,29 +143,31 @@ function ResultsPagination({ page, totalPages }: { page: number; totalPages: num
143143
}
144144

145145
return (
146-
<Box borderRadius={2} p={2}>
147-
<Pagination
148-
pageCount={Math.min(totalPages, 10)}
149-
currentPage={page}
150-
hrefBuilder={hrefBuilder}
151-
onPageChange={(event, page) => {
152-
event.preventDefault()
146+
<div className={styles.paginationFocus}>
147+
<Box borderRadius={2} p={2}>
148+
<Pagination
149+
pageCount={Math.min(totalPages, 10)}
150+
currentPage={page}
151+
hrefBuilder={hrefBuilder}
152+
onPageChange={(event, page) => {
153+
event.preventDefault()
153154

154-
const [asPathRoot, asPathQuery = ''] = router.asPath.split('#')[0].split('?')
155-
const params = new URLSearchParams(asPathQuery)
156-
if (page !== 1) {
157-
params.set('page', `${page}`)
158-
} else {
159-
params.delete('page')
160-
}
161-
let asPath = `/${router.locale}${asPathRoot}`
162-
if (params.toString()) {
163-
asPath += `?${params}`
164-
}
165-
setAsPath(asPath)
166-
router.push(asPath)
167-
}}
168-
/>
169-
</Box>
155+
const [asPathRoot, asPathQuery = ''] = router.asPath.split('#')[0].split('?')
156+
const params = new URLSearchParams(asPathQuery)
157+
if (page !== 1) {
158+
params.set('page', `${page}`)
159+
} else {
160+
params.delete('page')
161+
}
162+
let asPath = `/${router.locale}${asPathRoot}`
163+
if (params.toString()) {
164+
asPath += `?${params}`
165+
}
166+
setAsPath(asPath)
167+
router.push(asPath)
168+
}}
169+
/>
170+
</Box>
171+
</div>
170172
)
171173
}

0 commit comments

Comments
 (0)