Skip to content

fix(components): [virtual-list] incorrect scroll boundary check#23289

Merged
btea merged 1 commit into
devfrom
fix/virtual-list-reached-edge
Jan 4, 2026
Merged

fix(components): [virtual-list] incorrect scroll boundary check#23289
btea merged 1 commit into
devfrom
fix/virtual-list-reached-edge

Conversation

@rzzf
Copy link
Copy Markdown
Member

@rzzf rzzf commented Jan 3, 2026

After rapidly scrolling upward with a mouse or trackpad, offset becomes negative. When scrolling downward slowly afterward, both offset and offset + newOffset remain 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

  • Bug Fixes
    • Enhanced virtual list scroll behavior to allow smoother movement in additional scenarios when approaching edge boundaries.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 3, 2026

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 3, 2026

📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Wheel Handler Edge Detection
packages/components/virtual-list/src/hooks/use-wheel.ts
Modified edge-check logic: early-return condition now checks only the next offset reaching an edge rather than requiring both current and next offsets.

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

CommitMessage::Unqualified

Suggested reviewers

  • Dsaquel
  • btea

Poem

🐰 I nudge the wheel with careful paws tonight,
One step ahead I see the edge in sight.
No double-check, just the next hop's cue,
I hop, the list scrolls—smooth and new! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: fixing an incorrect scroll boundary check in the virtual-list component.
Description check ✅ Passed The description adequately explains the bug, reproduction steps, and includes a working example link, but does not follow the repository's pull request template structure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4b04769 and 23d10b0.

📒 Files selected for processing (1)
  • packages/components/virtual-list/src/hooks/use-wheel.ts

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jan 3, 2026

Open in StackBlitz

pnpm add https://pkg.pr.new/element-plus/element-plus@23289
npm i https://pkg.pr.new/element-plus/element-plus@23289
yarn add https://pkg.pr.new/element-plus/[email protected]

commit: 23d10b0

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 3, 2026

Size Change: -22 B (0%)

Total Size: 1.6 MB

Filename Size Change
./dist/element-plus/dist/index.full.js 459 kB -6 B (0%)
./dist/element-plus/dist/index.full.min.js 323 kB -6 B (0%)
./dist/element-plus/dist/index.full.min.mjs 318 kB -5 B (0%)
./dist/element-plus/dist/index.full.mjs 450 kB -5 B (0%)
ℹ️ View Unchanged
Filename Size
./dist/element-plus/dist/index.css 46.7 kB

compressed-size-action

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a 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

🧹 Nitpick comments (1)
packages/components/virtual-list/src/hooks/use-wheel.ts (1)

22-27: Consider adding clarifying comment for edge detection logic.

The hasReachedEdge function'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

📥 Commits

Reviewing files that changed from the base of the PR and between 4b04769 and 23d10b0.

📒 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 + newOffset to checking only newOffset correctly 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): newOffset direction matches the edge we've reached
  • Scrolling away from an edge (allowed): newOffset direction is opposite to the edge

This prevents the scenario where rapid scrolling accumulates a large offset before the frame executes, causing the old offset + newOffset check to incorrectly block scrolling in the opposite direction.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 3, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 85.34% 17794 / 20849
🔵 Statements 84.14% 18622 / 22132
🔵 Functions 83.82% 4793 / 5718
🔵 Branches 73.57% 10170 / 13822
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
packages/components/virtual-list/src/hooks/use-wheel.ts 23.8% 0% 25% 25% 24, 26, 30, 32, 34-37, 35-36, 39, 41, 41, 43, 45-47, 46, 49-52, 50-51
Generated in workflow #510

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 3, 2026

🧪 Playground Preview: https://element-plus.run/?pr=23289
Please comment the example via this playground if needed.

@rzzf
Copy link
Copy Markdown
Member Author

rzzf commented Jan 3, 2026

@coderabbitai summary

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 3, 2026

✅ Actions performed

Summary regeneration triggered.

@btea btea merged commit 71e5216 into dev Jan 4, 2026
21 checks passed
@btea btea deleted the fix/virtual-list-reached-edge branch January 4, 2026 06:35
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 4, 2026

@rzzf Thanks for your contribution! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants