ATM when on the first or last page of the pagination component, a Link component is generated with no href attribute for the first / last page and previous / next page elements of the pagination.
Issue : Since NextJS can't handle Link without an href attribute, the whole page crashes if we're on the first or last page of the pagination component.
Steps to reproduce : Clone react-dsfr, use a Pagination component in test/integration/next-appdir/ui/ClientComponent.tsx.
Set defaultPage attribue to either 1 or the same as count count attribute, and count > 1.
Run and try to access the page.
Solution :
I tried to solve this in the most simple and straight forward way :
If we're on either the first or last page of the Pagination component, then we use a <a> HTML element instead of <Link> for those specific action links.
Since the link is not clickable anyway in such case, this should not cause any issue or regression.
ATM when on the first or last page of the pagination component, a
Link
component is generated with nohref
attribute for thefirst / last page
andprevious / next page
elements of the pagination.The issue seem to have been running for almost a year now https://github.com/codegouvfr/react-dsfr/issues/170
Issue : Since NextJS can't handle
Link
without anhref
attribute, the whole page crashes if we're on the first or last page of the pagination component.Steps to reproduce : Clone react-dsfr, use a Pagination component in
test/integration/next-appdir/ui/ClientComponent.tsx
.Set
defaultPage
attribue to either 1 or the same ascount
count attribute, andcount
> 1. Run and try to access the page.example :
Solution : I tried to solve this in the most simple and straight forward way : If we're on either the first or last page of the Pagination component, then we use a
<a>
HTML element instead of<Link>
for those specific action links.Since the link is not clickable anyway in such case, this should not cause any issue or regression.