-
Notifications
You must be signed in to change notification settings - Fork 61
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
fix(web): Generic List - Reset page number when filters are changed #17141
fix(web): Generic List - Reset page number when filters are changed #17141
Conversation
WalkthroughThe changes in this pull request focus on the Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17141 +/- ##
==========================================
- Coverage 35.74% 35.74% -0.01%
==========================================
Files 6925 6925
Lines 147569 147571 +2
Branches 42010 42010
==========================================
Hits 52747 52747
- Misses 94822 94824 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
|
Datadog ReportBranch report: ✅ 0 Failed, 84 Passed, 0 Skipped, 34.79s Total Time |
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
🧹 Outside diff range and nitpick comments (1)
apps/web/components/GenericList/GenericList.tsx (1)
Line range hint
314-481
: Consider centralizing page reset logicThe page reset logic is currently duplicated across different filter handlers. Consider extracting this into a custom hook or utility function to improve maintainability and ensure consistent behavior.
Example implementation:
const useFilterWithPageReset = ( setParameters: (value: Record<string, string[]> | null) => void, setPage: (value: number | null) => void, ) => { const updateFilters = ( updater: (prev: Record<string, string[]> | null) => Record<string, string[]> | null, ) => { setPage(null); setParameters(updater); }; return updateFilters; };This would centralize the page reset logic and could be used across all filter handlers.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
apps/web/components/GenericList/GenericList.tsx
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
apps/web/components/GenericList/GenericList.tsx (1)
Pattern apps/**/*
: "Confirm that the code adheres to the following:
- NextJS best practices, including file structure, API routes, and static generation methods.
- Efficient state management and server-side rendering techniques.
- Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (2)
apps/web/components/GenericList/GenericList.tsx (2)
Line range hint 314-339
: LGTM: Correctly resets page when removing filters
The addition of setPage(null)
ensures that the page number resets to 1 when a filter is removed, which aligns with the expected behavior and fixes the reported issue.
Line range hint 469-481
: LGTM: Correctly resets page when adding filters
The addition of setPage(null)
ensures that the page number resets to 1 when a new filter is added, maintaining consistent behavior with filter removal and completing the fix for the reported issue.
…17141) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Generic List - Reset page number when filters are changed
What
Screenshots / Gifs
This will fix this issue:
Screen.Recording.2024-12-05.at.12.26.21.mov
Checklist:
Summary by CodeRabbit
New Features
GenericList
component, ensuring pagination resets when filters are applied or modified.Bug Fixes