fix(pagination): allow single page display by updating range condition
Description
This PR fixes the pagination component not displaying page numbers when there's only one page (resolves #1048).
Changes Made
-
Updated
packages/ui/src/components/Pagination/helpers.ts:- Changed condition from
start >= endtostart > endin therangefunction - Updated JSDoc to reflect the new behavior
- Added example showing
range(1, 1)returns[1]
- Changed condition from
Problem Solved
Previously, when the pagination component had only one page, the page number "1" would not be displayed, showing only disabled previous/next buttons. This was caused by the range function returning an empty array when start === end.
With this change:
-
range(1, 1)now returns[1]instead of[] - Single page scenarios properly display the page number
- All existing behavior for multi-page scenarios is preserved
Related Issues
- Fixes #1048
- Resolves the stale PR #1240 by implementing the same core fix
Testing
The existing test suite in helpers.test.ts already includes test cases that validate this behavior, including range(8, 9).toEqual([8, 9]) which confirms single-page ranges work correctly.
Checklist
- [x] I have followed the Your First Code Contribution section of the Contributing guide
- [x] Code changes are minimal and focused on the specific issue
- [x] No breaking changes to existing API
- [x] JSDoc updated to reflect new behavior…tion): allow range function to return single page (fixes #1048)Update helpers.ts
Changed condition from start >= end to start > end to allow range function to return [start] when start equals end. This fixes the pagination component not showing page 1 when there's only one page. Addresses issue #1048.
- [ ] I have followed the Your First Code Contribution section of the Contributing guide
Summarize the changes made and the motivation behind them.
Reference related issues using # followed by the issue number.
If there are breaking API changes - like adding or removing props, or changing the structure of the theme - describe them, and provide steps to update existing code.
Summary by CodeRabbit
-
Bug Fixes
- Pagination now correctly handles equal start/end boundaries, showing a single item/page instead of an empty result. This ensures consistent display for edge cases and avoids missing pagination elements.
-
Documentation
- Clarified boundary behavior in the pagination docs to reflect inclusive end handling.
- Added an example demonstrating the equal-boundary case.
⚠️ No Changeset found
Latest commit: 1a7c19c39521d5ebe859db8a459cd7161b34590d
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/DHANUSHRAJA22/flowbite-react/new/fix/pagination-single-page?filename=.changeset/angry-keys-rule.md&value=---%0A%22flowbite-react%22%3A%20patch%0A---%0A%0Afix(pagination)%3A%20allow%20single%20page%20display%20by%20updating%20range%20condition%20(resolves%20%231048)fix(pagination)%3A%20allow%20single%20page%20display%20by%20updating%20range%20function%20condition%20(resolves%20%231048)fix(pagination)%3A%20allow%20range%20function%20to%20return%20single%20pagefix(pagina%E2%80%A6%0A)
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| flowbite-react | Preview | Comment | Aug 27, 2025 11:02am | |
| flowbite-react-storybook | Preview | Comment | Aug 27, 2025 11:02am |
Walkthrough
Adjusts the Pagination helper’s range function to include the end value when start equals end (returning [start] for start == end). Updates inline documentation accordingly. No exported APIs changed.
Changes
| Cohort / File(s) | Summary |
|---|---|
Pagination helper: inclusive end in rangepackages/ui/src/components/Pagination/helpers.ts |
Change empty-case check from start >= end to start > end; update comments/docs; add example for equal-boundary case. |
Sequence Diagram(s)
sequenceDiagram
autonumber
actor UI as Pagination UI
participant Helper as helpers.ts (range)
UI->>Helper: range(start=1, end=1)
Note right of Helper: New behavior: inclusive end when start==end
Helper-->>UI: [1]
Note over UI: UI renders single page "1"
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
| Fix single-page Pagination so "1" is rendered by adjusting range condition (#1048) | ✅ |
Assessment against linked issues: Out-of-scope changes
Suggested reviewers
- rluders
Poem
I nibbled the bounds of a range tonight,
Tweaked a carrot-shaped “>=” to “>” just right.
Now page one hops in, crisp and clean,
Between two arrows, proudly seen.
Thump-thump! A single hop to cheer—
One page, one number, loud and clear. 🥕🐇
[!TIP]
🔌 Remote MCP (Model Context Protocol) integration is now available!
Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
🧪 Generate unit tests
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
-
I pushed a fix in commit <commit_id>, please review it. -
Open a follow-up GitHub issue for this discussion.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. - PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase. -
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
-
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
CodeRabbit Commands (Invoked using PR/Issue comments)
Type @coderabbitai help to get the list of available commands.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Status, Documentation and Community
- Visit our Status Page to check the current availability of CodeRabbit.
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.