-
Notifications
You must be signed in to change notification settings - Fork 4
86b7gfrw5 - fix: pagination on sponsor forms when rows per page change #758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThe pull request renames the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/actions/sponsor-forms-actions.js (1)
117-132: CapcurrentPagetolastPagewhen perPage changes.Line 131 only resets when
perPage > totalCount. IfperPageincreases but still <=totalCount,currentPagecan still exceed the last page (e.g., totalCount=50, perPage=25, currentPage=3). This will keep sending an invalid page and can still trigger the backend error you’re trying to avoid. Consider computinglastPageand cappingcurrentPage.🐛 Proposed fix
- // Resets page to avoid backend error. - const page = perPage > totalCount ? 1 : currentPage; + // Reset/cap page to avoid backend errors. + const safeTotal = Number.isFinite(totalCount) ? totalCount : 0; + const lastPage = Math.max(1, Math.ceil(safeTotal / perPage)); + const page = Math.min(currentPage, lastPage);
🧹 Nitpick comments (1)
src/actions/__tests__/sponsor-forms-actions.test.js (1)
62-121: Add a test forcurrentPage > lastPagewhen perPage changes.Right now the tests don’t cover the scenario where
perPagechanges butcurrentPageis now beyond the last page (even ifperPage <= totalCount). Adding a test will lock in the intended cap behavior once the fix above is applied.✅ Suggested test case
+ it("should cap page to last page when currentPage exceeds last page after perPage change", async () => { + const store = mockStore({ + currentSummitState: { currentSummit: {} }, + sponsorFormsListState: { totalCount: 50 } + }); + + store.dispatch(getSponsorForms("", 5, 25, "id", 1, false, [])); + await flushPromises(); + + expect(getRequest).toHaveBeenCalledWith( + expect.anything(), + expect.anything(), + expect.anything(), + expect.anything(), + { + hideArchived: false, + order: "id", + orderDir: 1, + page: 2, + perPage: 25, + term: "" + } + ); + });
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/actions/__tests__/sponsor-forms-actions.test.jssrc/actions/sponsor-forms-actions.js
🧰 Additional context used
🧬 Code graph analysis (2)
src/actions/sponsor-forms-actions.js (4)
src/reducers/sponsors/sponsor-form-items-list-reducer.js (1)
currentPage(79-83)src/reducers/sponsors/sponsor-forms-list-reducer.js (3)
currentPage(95-99)currentPage(190-194)currentPage(222-227)src/reducers/sponsors/sponsor-page-forms-list-reducer.js (2)
currentPage(96-100)currentPage(138-142)src/utils/constants.js (6)
DEFAULT_CURRENT_PAGE(73-73)DEFAULT_CURRENT_PAGE(73-73)DEFAULT_PER_PAGE(75-75)DEFAULT_PER_PAGE(75-75)DEFAULT_ORDER_DIR(91-91)DEFAULT_ORDER_DIR(91-91)
src/actions/__tests__/sponsor-forms-actions.test.js (1)
src/actions/sponsor-forms-actions.js (2)
getSponsorForms(106-168)getSponsorForms(106-168)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build
- GitHub Check: build
- GitHub Check: build
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
ref: https://app.clickup.com/t/86b7gfrw5
86b7gfrw5 - fix: pagination on sponsor forms when rows per page change
Changelog
totalCountand pagesperPagesselected.Links
86b7gfrw5 - Pagination does not function, throws error
Evidence
2026-01-16_15-09-29.-.evidence.-.86b7gfrw5.mp4
Summary by CodeRabbit
Tests
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.