ui icon indicating copy to clipboard operation
ui copied to clipboard

Nesting PaginationLink/PaginationPrevious/PaginationNext inside PaginationItem produces nested li elements

Open dngpng opened this issue 1 year ago • 5 comments

The Issue

The example given in the docs for Pagination component wraps PaginationLink / PaginationPrevious / PaginationNext components with a PaginationItem. However the code for PaginationLink actually already wraps the content inside a PaginationItem, the example will therefore result in a nested PaginationItems (meaning nested li-elements) -- this will lead to React reporting an error during rendering.

image

Possible Solutions

  1. Do not internalize PaginationItem inside a PaginationLink, this way we will have a uniform behavior when constructing a Pagination tree.

  2. Fix the example in the doc so that PaginationLink / PaginationPrevious / PaginationNext are used directly without being wrapped (again) in a PaginationItem

dngpng avatar Dec 23 '23 09:12 dngpng

Yes, can confirm it produces nested li tags.

Screenshot 2023-12-24 at 1 15 13 PM

plsankar avatar Dec 24 '23 07:12 plsankar

I have the same issue. I will try and make a PR.

stathis1998 avatar Jan 10 '24 19:01 stathis1998

Any update on this ?

Currently as a workaround, I have replaced the PaginationLink with custom PaginationButton components. That solves the problem for now.

css "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-accent hover:text-accent-foreground h-9 w-9"

Screenshot 2024-01-28 at 00 46 13 Screenshot 2024-01-28 at 00 50 33

HR555 avatar Jan 27 '24 18:01 HR555

Any update on this ?

Currently as a workaround, I have replaced the PaginationLink with custom PaginationButton components. That solves the problem for now.

css "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-accent hover:text-accent-foreground h-9 w-9"

Screenshot 2024-01-28 at 00 46 13

This has been resolved if I am not mistaken. It was merged on another's guy PR.

stathis1998 avatar Jan 27 '24 19:01 stathis1998

Yes, https://github.com/shadcn-ui/ui/pull/2416

HR555 avatar Jan 28 '24 14:01 HR555

This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.

shadcn avatar Feb 20 '24 23:02 shadcn