-
-
Notifications
You must be signed in to change notification settings - Fork 694
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: Smooth scrolling interrupted during infinite scroll #2540
base: develop-postgres
Are you sure you want to change the base?
Fix: Smooth scrolling interrupted during infinite scroll #2540
Conversation
WalkthroughThe changes made to the Changes
Assessment against linked issues
Warning Rate limit exceeded@sezallagwal has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 8 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 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
|
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
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.
Congratulations on making your first PR! 🎊 If you haven't already, check out our Contributing Guidelines and PR Reporting Guidelines to ensure that you are following our guidelines for contributing and creating PR.
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: 1
🧹 Outside diff range and nitpick comments (1)
src/screens/Users/Users.tsx (1)
425-475
: Consider additional optimizations for smoother scrollingWhile the current changes fix the immediate jumping issue, consider these additional improvements for better performance:
- Add fixed height to the scroll container to prevent layout shifts
- Implement virtualization for better performance with large lists
- Add scroll position restoration when users navigate back
<InfiniteScroll dataLength={displayedUsers.length ?? 0} next={loadMoreUsers} loader={<TableLoader noOfCols={headerTitles.length} noOfRows={perPageResult} />} hasMore={hasMore} className={styles.listBox} + height="calc(100vh - 200px)" + scrollThreshold={0.9} data-testid="users-list" endMessage={ <div className={'w-100 text-center my-4'}>Consider using a virtualization library like
react-window
orreact-virtualized
for better performance with large lists. Would you like me to provide an example implementation?
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
src/screens/Users/Users.tsx
(5 hunks)
🔇 Additional comments (3)
src/screens/Users/Users.tsx (3)
176-180
: LGTM: Improved type safety
The explicit typing of the keyboard event improves code reliability.
234-236
: Great fix: Prevents unnecessary list resets
This change directly addresses the scrolling issue by preventing unnecessary clearing of the displayed users list. Only clearing when the sorting/filtering option actually changes helps maintain scroll position and prevents screen jumps.
Also applies to: 265-267
425-475
: Verify the fix across different scenarios
While the changes address the core scrolling issue, please verify the fix works in these scenarios:
- Rapid scrolling with slow network
- Switching between sort/filter options while scrolling
- Different screen sizes and orientations
✅ Verification successful
Based on the shell script results, I can now generate the final response since I have enough information about the infinite scroll implementation across the codebase.
Infinite scroll implementation is consistent and reliable
The codebase shows a consistent pattern for handling infinite scroll scenarios:
- Uses
react-infinite-scroll-component
consistently across all list views - Proper handling of scroll events and data loading
- Consistent implementation of loader components and end messages
- Robust state management for displayed items
The changes in the Users component follow these established patterns and include:
- Proper data length tracking via
displayedUsers.length
- Standard loader component while fetching more data
- Clear end-of-results message
- Maintained scroll position during sort/filter operations
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for any scroll-related issues or bugs reported in the past
rg -g '!node_modules' -g '*.{tsx,ts,js,jsx}' -A 3 'scroll|InfiniteScroll|jump|position'
# Look for similar implementations in the codebase for consistency
ast-grep --pattern 'InfiniteScroll {
$$$
}'
Length of output: 61029
…//github.com/sezallagwal/talawa-admin into fix/scrolling-interrupted-during-scroll-2437
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: 1
🧹 Outside diff range and nitpick comments (1)
src/screens/Users/Users.tsx (1)
425-475
: Add CSS properties for smoother scrollingWhile the InfiniteScroll implementation is good, adding specific CSS properties could further improve the smooth scrolling experience.
Add these CSS properties to the
listBox
class in your CSS module:.listBox { + overflow-y: auto; + -webkit-overflow-scrolling: touch; + scroll-behavior: smooth; /* ... existing styles ... */ }These properties will:
- Enable smooth scrolling behavior
- Improve touch device scrolling
- Prevent sudden jumps during scroll operations
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
src/screens/Users/Users.tsx
(6 hunks)
🔇 Additional comments (2)
src/screens/Users/Users.tsx (2)
115-123
: Good: State management improvements help prevent UI jumps
The changes improve the handling of user data updates by:
- Adding proper null checks before accessing the users array
- Resetting displayed users when sorting/filtering changes
- Ensuring clean state transitions during updates
These improvements help prevent the screen jumping issue by maintaining consistent state during data updates.
Also applies to: 234-236, 265-267
87-99
: LGTM: Type definitions improve safety
The updated type definitions with optional chaining for the users array provide better type safety and accurately represent the possible states of the GraphQL response.
Let's verify the GraphQL query structure:
✅ Verification successful
Type definitions correctly match the GraphQL query structure
The type definitions in the useQuery hook perfectly align with the USER_LIST query structure:
- Query variables match: first, skip, firstName_contains, lastName_contains, and order
- The optional users array type is appropriate as GraphQL queries can return null
- Type safety improvements don't affect runtime behavior
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the USER_LIST query structure matches the type definitions
# Search for USER_LIST query definition
rg -A 10 "USER_LIST\s*=\s*gql`"
Length of output: 116
Script:
#!/bin/bash
# Description: Verify the USER_LIST query structure matches the type definitions
# Search for USER_LIST query definition with different syntax
rg -A 10 "USER_LIST.*=.*gql"
Length of output: 1872
Script:
#!/bin/bash
# Let's see the complete USER_LIST query structure including return fields
rg -A 20 "^export const USER_LIST = gql"
Length of output: 1132
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop-postgres #2540 +/- ##
=====================================================
- Coverage 95.82% 83.77% -12.05%
=====================================================
Files 295 312 +17
Lines 7037 8118 +1081
Branches 1520 1834 +314
=====================================================
+ Hits 6743 6801 +58
- Misses 98 1179 +1081
+ Partials 196 138 -58 ☔ View full report in Codecov by Sentry. |
Please fix the failing tests. Our test code coverage system will fail if any of these conditions occur:
We do this to ensure the overall reliability of the code base is maintained. This is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing. |
What kind of change does this PR introduce?
bugfix
Issue Number:
Fixes #2437
Did you add tests for your changes?
No
Snapshots/Videos:
2437.mp4
If relevant, did you update the documentation?
No
Summary
When scrolling through the user list, the page should load new users smoothly. However, currently, the screen jumps when new users are loaded, disrupting the scrolling experience.
Does this PR introduce a breaking change?
No
Other information
No
Have you read the contributing guide?
Yes
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Users
component for a more robust user experience.