fix(components): [virtual-list] incorrect scroll boundary check#23289
Conversation
📝 WalkthroughWalkthroughThe wheel handler's edge-detection logic was changed: the early-return now triggers based on the next offset alone reaching an edge, instead of requiring both the current and next offsets to reach an edge. Changes
Sequence Diagram(s)(omitted — change is localized and does not introduce multi-component sequential flow) Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
Comment |
commit: |
|
Size Change: -22 B (0%) Total Size: 1.6 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/components/virtual-list/src/hooks/use-wheel.ts (1)
22-27: Consider adding clarifying comment for edge detection logic.The
hasReachedEdgefunction's behavior might benefit from a brief comment explaining that it returns true only when attempting to scroll further in the direction of an already-reached edge, not when scrolling away from it. This would make the intent clearer for future maintainers.Suggested documentation
const hasReachedEdge = (offset: number) => { + // Returns true only when trying to scroll further past an edge: + // - negative offset while at start edge, or positive offset while at end edge const edgeReached = (offset < 0 && atStartEdge.value) || (offset > 0 && atEndEdge.value) return edgeReached }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/components/virtual-list/src/hooks/use-wheel.ts
⏰ 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). (10)
- GitHub Check: Build ubuntu-latest LTS
- GitHub Check: Build windows-latest LTS
- GitHub Check: Coverage
- GitHub Check: SSR rendering test
- GitHub Check: build
- GitHub Check: Unit Test (Current)
- GitHub Check: Lint
- GitHub Check: Unit Test (New)
- GitHub Check: Unit Test (LTS)
- GitHub Check: size-report
🔇 Additional comments (1)
packages/components/virtual-list/src/hooks/use-wheel.ts (1)
41-41: Correct fix for the edge-detection bug.The change from checking
offset + newOffsetto checking onlynewOffsetcorrectly resolves the issue where accumulated negative offset prevented scrolling away from an edge. The new logic properly distinguishes between:
- Scrolling further into an edge (blocked):
newOffsetdirection matches the edge we've reached- Scrolling away from an edge (allowed):
newOffsetdirection is opposite to the edgeThis prevents the scenario where rapid scrolling accumulates a large offset before the frame executes, causing the old
offset + newOffsetcheck to incorrectly block scrolling in the opposite direction.
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
|
🧪 Playground Preview: https://element-plus.run/?pr=23289 |
|
@coderabbitai summary |
✅ Actions performedSummary regeneration triggered. |
|
@rzzf Thanks for your contribution! ❤️ |

After rapidly scrolling upward with a mouse or trackpad,
offsetbecomes negative. When scrolling downward slowly afterward, bothoffsetandoffset + newOffsetremain negative, causing the boundary check to keep failing and preventing the list from scrolling down.This issue doesn’t seem easy to reproduce in the playground. It may be better to verify it locally.
play
video
20260103-170343.mp4
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.