fix: show page number when totalPages equals 1 in Pagination#1670
fix: show page number when totalPages equals 1 in Pagination#1670polpo666 wants to merge 1 commit intothemesberg:mainfrom
Conversation
The range() helper was returning an empty array when start >= end, but it should return a single element when start equals end (i.e., totalPages = 1). This fixes the bug where the current page number was not displayed when there is only one page in the Pagination component. Fixes themesberg#1048
|
|
Someone is attempting to deploy a commit to the Bergside Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/ui/src/components/Pagination/helpers.ts (1)
5-5:⚠️ Potential issue | 🟡 MinorUpdate JSDoc to match the new boundary behavior.
The return description on Line 5 still says “greater than or equal to end,” but the function now returns
[]only whenstart > end.📝 Suggested doc fix
- * `@returns` An array of numbers from start to end. Returns empty array if start is greater than or equal to end. + * `@returns` An array of numbers from start to end. Returns empty array if start is greater than end.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/ui/src/components/Pagination/helpers.ts` at line 5, Update the JSDoc for the range function in packages/ui/src/components/Pagination/helpers.ts: change the `@returns` description to state that the function returns an empty array when start > end (not "greater than or equal to end"), so the docs match the current implementation of range.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@packages/ui/src/components/Pagination/helpers.ts`:
- Line 5: Update the JSDoc for the range function in
packages/ui/src/components/Pagination/helpers.ts: change the `@returns`
description to state that the function returns an empty array when start > end
(not "greater than or equal to end"), so the docs match the current
implementation of range.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a8991189-1357-4b8c-a6e3-70bb74dda1c2
📒 Files selected for processing (2)
packages/ui/src/components/Pagination/helpers.test.tspackages/ui/src/components/Pagination/helpers.ts
Summary
Fixes issue #1048 - "Pagination is broken if there is only one page".
The
range()helper was returning an empty array whenstart >= end, but it should return a single element whenstart === end(i.e., whentotalPages = 1).Changes
helpers.ts: Changed condition fromstart >= endtostart > endVerification
Tested manually:
range(1, 1)returns[1](single page) ✓range(1, 5)returns[1, 2, 3, 4, 5](normal case) ✓range(20, 10)returns[](invalid range) ✓Breaking changes
None.
Summary by CodeRabbit