themesberg / themesberg/flowbite-react
Pagination is broken if there is only one page
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.1k
- Forks
- 506
- PR merge metrics
- No merged PRs in 30d
Description
- I have searched the Issues to see if this bug has already been reported
- I have tested the latest version
Steps to reproduce
- Render pagination component with this props:
<Pagination
currentPage={1}
totalPages={1}
showIcons
nextLabel=""
previousLabel=""
/>
Current behavior
There is no 1 between the arrows, just two buttons (previous and next)
Expected behavior
1 is shown between the arrows, similarly to the case when we have 2 and more pages.
Context
I would like to show the Pagination component with only one page when user has a small amount of data.
The problem is in range function, where this check is contained
if (start >= end) {
return [];
}
I would assume it should be
if (start > end) {
return [];
}
but not sure whether this breaks the expected behaviour from your side. If you are fine I can create the PR.
Thanks,
Sergii
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the shown Pagination props, then inspect the Pagination component and its range function. Verify the single-page case and confirm that page 1 appears between the previous and next buttons without changing the multi-page behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100