Skip to content

Commit

Permalink
Merge branch 'main' into chore/update-octicons-react-in-lockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
joshblack authored Jan 7, 2025
2 parents 570d60c + e352e19 commit c4bbbcb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/eighty-carpets-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

Pagination: Hides the `Pagination` Previous and Next buttons from the accessibility tree when they are disabled.
20 changes: 16 additions & 4 deletions packages/react/src/Pagination/Pagination.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, {useState} from 'react'
import type {Meta, StoryFn} from '@storybook/react'
import type {ComponentProps} from '../utils/types'
import Pagination from './Pagination'
Expand Down Expand Up @@ -26,9 +26,21 @@ const parseShowPagesArg = (value: boolean | string) => {
}
}

export const Default = () => (
<Pagination pageCount={15} currentPage={2} onPageChange={e => e.preventDefault()} showPages={{narrow: false}} />
)
export const Default = () => {
const [page, setPage] = useState(2)

return (
<Pagination
pageCount={15}
currentPage={page}
onPageChange={(e, n) => {
e.preventDefault()
setPage(n)
}}
showPages={{narrow: false}}
/>
)
}

export const Playground: StoryFn<ComponentProps<typeof Pagination>> = ({showPages, ...args}) => {
return (
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/Pagination/model.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export function buildComponentData(
key = 'page-prev'
content = 'Previous'
if (page.disabled) {
Object.assign(props, {'aria-disabled': 'true', role: 'link'})
Object.assign(props, {'aria-hidden': 'true'})
} else {
Object.assign(props, {
rel: 'prev',
Expand All @@ -163,7 +163,7 @@ export function buildComponentData(
key = 'page-next'
content = 'Next'
if (page.disabled) {
Object.assign(props, {'aria-disabled': 'true', role: 'link'})
Object.assign(props, {'aria-hidden': 'true'})
} else {
Object.assign(props, {
rel: 'next',
Expand Down

0 comments on commit c4bbbcb

Please sign in to comment.