trussworks / react-uswds

USWDS 3.0 components built in React
https://trussworks.github.io/react-uswds/
Apache License 2.0
169 stars 78 forks source link

[feat] Add Page Number Value to Pagination Buttons #2948

Open etanb opened 3 weeks ago

etanb commented 3 weeks ago

Does your feature request relate to a specific USWDS component?

Pagination specifically: https://github.com/trussworks/react-uswds/blob/main/src/components/Pagination/Pagination.tsx

What USWDS Version is this feature present in?

ALL

Is your feature request related to a problem? Please describe.

As of now, the only way to get the value of which page a user clicked within a Pagination component is by the .innerText. We should not be storing and reading values based on DOM strings.

Describe the solution you'd like

Simply add a value={page} or data-page={page} with the actual page number value for better readability and structure:

https://github.com/trussworks/react-uswds/blob/main/src/components/Pagination/Pagination.tsx#L43-L54