Skip to content

Conversation

QdabuliuQ
Copy link
Contributor

@QdabuliuQ QdabuliuQ commented Jul 16, 2025

๐Ÿค” This is a ...

  • ๐Ÿ†• New feature
  • ๐Ÿž Bug fix
  • ๐Ÿ“ Site / documentation improvement
  • ๐Ÿ“ฝ๏ธ Demo improvement
  • ๐Ÿ’„ Component style improvement
  • ๐Ÿค– TypeScript definition improvement
  • ๐Ÿ“ฆ Bundle size optimization
  • โšก๏ธ Performance optimization
  • โญ๏ธ Feature enhancement
  • ๐ŸŒ Internationalization
  • ๐Ÿ›  Refactoring
  • ๐ŸŽจ Code style optimization
  • โœ… Test Case
  • ๐Ÿ”€ Branch merge
  • โฉ Workflow
  • โŒจ๏ธ Accessibility improvement
  • โ“ Other (about what?)

๐Ÿ”— Related Issues

fix ant-design/ant-design#53924
fix ant-design/ant-design#54548

๐Ÿ’ก Background and Solution

้€‰ๆ‹ฉๆ–‡ๆœฌ๏ผŒ้ผ ๆ ‡ๆŒ‰ไฝๆ–‡ๆœฌๆ‹–ๆ‹ฝๅˆฐ่กจๆ ผๅค–่พน๏ผŒๆพๅผ€้ผ ๆ ‡๏ผŒ้ผ ๆ ‡ไธŠไธ‹็งปๅŠจไผš่งฆๅ‘่กจๆ ผๆปšๅŠจ

467032935-9bec2f1c-866f-40d0-be9e-b6e19b6c0be8.mov

rc-virtual-list ็š„ useScrollDrag hook ็›‘ๅฌ mouseup

๐Ÿ“ Change Log

Language Changelog
๐Ÿ‡บ๐Ÿ‡ธ English Fix virtual-list drag scrolling issue
๐Ÿ‡จ๐Ÿ‡ณ Chinese ไฟฎๅค virtual-list ๆ‹–ๆ‹ฝๆปšๅŠจๅผ‚ๅธธ

Summary by CodeRabbit

  • Bug Fixes

    • ไฟฎๅคๅœจๅˆ—่กจไธญๆ‹–ๆ‹ฝๅนถๆ”พไธ‹้€‰ไธญๆ–‡ๆœฌๅŽๅฏ่ƒฝ็ปง็ปญ่งฆๅ‘ๆปšๅŠจ็š„้—ฎ้ข˜๏ผšๅœจๆ–‡ๆกฃ็บงๅˆซๅค„็†้ผ ๆ ‡ๆพๅผ€ไธŽๅŽŸ็”Ÿๆ‹–ๆ‹ฝ็ป“ๆŸไบ‹ไปถไปฅๆญฃ็กฎ็ปˆๆญขๆ‹–ๆ‹ฝๆปšๅŠจ๏ผŒๆๅ‡ไบคไบ’็จณๅฎšๆ€งใ€‚
  • Tests

    • ๆ–ฐๅขžๅ›žๅฝ’ๆต‹่ฏ•๏ผŒ้ชŒ่ฏๆ‹–ๆ‹ฝๅนถๆ”พไธ‹ๆ–‡ๆœฌไธไผš่งฆๅ‘้ขๅค–ๆปšๅŠจๆˆ–ๆปšๅŠจๅ›ž่ฐƒใ€‚

The package version was changed from 3.19.2 to 3.19.1, possibly to correct a versioning error or revert a previous update.
Copy link

vercel bot commented Jul 16, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
virtual-list Ready Ready Preview Comment Sep 10, 2025 6:37am

Copy link

coderabbitai bot commented Jul 16, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

ๅœจ useScrollDrag ้’ฉๅญๅ†…ๆ–ฐๅขžๅนถไฝฟ็”จ clearDragState() ้›†ไธญ้‡็ฝฎๆ‹–ๆ‹ฝ็Šถๆ€ไธŽๅœๆญขๆปšๅŠจ๏ผ›ๅฐ†ๅŽŸๆœ‰็ป„ไปถๅ†…่”็š„ onMouseUp ๆ›ฟๆขไธบ document ๅฑ‚็š„ mouseup ไธŽ dragend ็›‘ๅฌๅนถๅœจ cleanup ไธญ็งป้™คใ€‚ๆ–ฐๅขžๆต‹่ฏ•้ชŒ่ฏๅœจ้€‰ไธญๆ–‡ๆœฌๅนถๆ‰ง่กŒๅŽŸ็”Ÿๆ‹–ๆ”พๆ—ถไธไผš่งฆๅ‘ๆปšๅŠจๅ›ž่ฐƒใ€‚

Changes

Cohort / File(s) ๅ˜ๆ›ดๆ‘˜่ฆ
Hook ๅฎž็Žฐๆ›ดๆ–ฐ
src/hooks/useScrollDrag.ts
ๆ–ฐๅขžๅ†…้ƒจ่พ…ๅŠฉๅ‡ฝๆ•ฐ clearDragState() ็”จไบŽ้‡็ฝฎๆ‹–ๆ‹ฝ็Šถๆ€ๅนถๅœๆญขๆปšๅŠจ๏ผ›็งป้™ค็ป„ไปถๅ†…่”็š„ onMouseUp๏ผŒๅœจ document ๅฑ‚ๆณจๅ†Œ mouseup ไธŽ dragend๏ผˆๅนถ็ป‘ๅฎš clearDragState๏ผ‰๏ผ›ๆ›ดๆ–ฐ cleanup ไปฅๆณจ้”€ๆ–ฐๅขž็š„ document ไบ‹ไปถ็›‘ๅฌ๏ผ›onMouseDown/onMouseMove ่กŒไธบไฟๆŒไธๅ˜ใ€‚
ๆต‹่ฏ•ๆ–ฐๅขž
tests/scroll.test.js
ๆ–ฐๅขž็”จไพ‹ should not scroll after dropping selected list text๏ผšๅœจๅฏนๅˆ—่กจ้กน้€‰ไธญๆ–‡ๆœฌๅนถๆจกๆ‹ŸๅŽŸ็”Ÿ dragstart/dragover/drop/dragend ๆต็จ‹ๅŽ๏ผŒๆ–ญ่จ€ onScroll ๅœจ drop/dragend ๆœŸ้—ดไธๅ†่ขซ่งฆๅ‘๏ผŒ้ชŒ่ฏๆ–‡ๆœฌๆ‹–ๆ”พไธไผš่งฆๅ‘ๆปšๅŠจใ€‚

Sequence Diagram(s)

sequenceDiagram
    participant User as ็”จๆˆท
    participant Document as Document
    participant Hook as useScrollDrag

    User->>Document: mousedown (ๅฏ่ƒฝ้€‰ไธญๆ–‡ๆœฌ)
    Document->>Hook: onMouseDown / onMouseMove (ไฟๆŒๅŽŸๆœ‰่กŒไธบ)
    Note right of Hook #DFF2E1: ๅฏ่ƒฝ่ฎพ็ฝฎ mouseDownLock\nๅนถ่งฆๅ‘ๆปšๅŠจ
    User->>Document: dragstart (ๅŽŸ็”Ÿ)
    Document->>Hook: dragstart (ไธๆ”นๅŠจ onMouseDown)
    Note right of Hook #FCE8D6: text selection + drag begins
    Document->>Hook: dragend -> clearDragState()
    Document->>Hook: mouseup -> clearDragState()
    Note right of Hook #FCE8D6: clearDragState ๅœๆญขๆปšๅŠจๅนถ้‡็ฝฎ้”\ndocument ็บงๅˆซ cleanup ็งป้™ค็›‘ๅฌๅ™จ
Loading

Estimated code review effort

๐ŸŽฏ 3 (Moderate) | โฑ๏ธ ~20 minutes

Possibly related PRs

  • fix: Skip scroll when draggable ย #304 โ€” ้’ˆๅฏน็›ธๅŒ useScrollDrag ้’ฉๅญ่ฐƒๆ•ดๆ‹–ๆ‹ฝ็›ธๅ…ณ่กŒไธบ๏ผŒไปฃ็ ๅฑ‚้ขไธŽๆœฌๆฌกๅฏนๆธ…็†/้˜ปๆญขๆปšๅŠจ็š„ๅ˜ๅŠจ้ซ˜ๅบฆ็›ธๅ…ณใ€‚
  • feat: mouse down to scrollย #293 โ€” ไฟฎๆ”นๅŒไธ€ๆ–‡ไปถ๏ผˆsrc/hooks/useScrollDrag.ts๏ผ‰็š„ไบ‹ไปถ็›‘ๅฌไธŽๆธ…็†้€ป่พ‘๏ผŒไธŽๆœฌๆฌกๆ”นๅŠจ็›ดๆŽฅ้‡ๅ ๅนถๅฏ่ƒฝๅ†ฒ็ชๆˆ–ไบ’่กฅใ€‚

Pre-merge checks (2 passed, 1 warning)

โŒ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage โš ๏ธ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
โœ… Passed checks (2 passed)
Check name Status Explanation
Description Check โœ… Passed Check skipped - CodeRabbitโ€™s high-level summary is enabled.
Title Check โœ… Passed PRๅฝ“ๅ‰ๆ ‡้ข˜ๆ˜Ž็กฎๆฆ‚ๆ‹ฌไบ†ไฟฎๅค็š„ๆ ธๅฟƒ้—ฎ้ข˜๏ผŒๅณๅœจ้€‰ไธญๅนถๆ‹–ๆ‹ฝๆ–‡ๆœฌๅŽๆพๅผ€้ผ ๆ ‡ไป็„ถ่งฆๅ‘่กจๆ ผๆปšๅŠจ๏ผŒไธŽๅฎž้™…ไฟฎๆ”นๅ†…ๅฎน้ซ˜ๅบฆไธ€่‡ด๏ผŒ่ƒฝๅคŸ่ฎฉๅฎก้˜…่€…ๅฟซ้€Ÿ็†่งฃๆœฌๆฌกๅ˜ๆ›ด็š„็›ฎ็š„ใ€‚

Poem

ๅฐๅ…”่ฝป่ทณๅฎˆ่พน็•Œ๏ผŒๆ–‡้€‰้™่ฝไธๆƒŠ้›ท๏ผŒ
ไบ‹ไปถๅœจๆ–‡ๆกฃๅค„ๆ”ถๅฐพ๏ผŒๆ‹–ๆ‹ฝๅฝ’ไฝ้ฃŽไบฆๆ‚„๏ผŒ
ๆธ…้”ไธ€ๅฃฐ๏ผŒๆปšๅŠจๆญข๏ผŒไปฃ็ ๅฎ‰็กๆขฆไธญ่นฆ ๐Ÿ‡โœจ

Tip

๐Ÿ‘ฎ Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks โ€“ Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks โ€“ Define your own rules using CodeRabbitโ€™s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbitโ€™s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


๐Ÿ“œ Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 294ab97 and f958296.

๐Ÿ“’ Files selected for processing (1)
  • src/hooks/useScrollDrag.ts (3 hunks)
๐Ÿšง Files skipped from review as they are similar to previous changes (1)
  • src/hooks/useScrollDrag.ts
โœจ Finishing Touches
  • ๐Ÿ“ Generate Docstrings
๐Ÿงช Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

โค๏ธ Share

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

@QdabuliuQ
Copy link
Contributor Author

bugๅค็Žฐdemo๏ผšhttps://stackblitz.com/edit/vitejs-vite-b3ssma5u?file=src%2FApp.tsx

Copy link

codecov bot commented Jul 17, 2025

Codecov Report

โœ… All modified and coverable lines are covered by tests.
โœ… Project coverage is 97.86%. Comparing base (5769845) to head (f958296).
โš ๏ธ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #328   +/-   ##
=======================================
  Coverage   97.85%   97.86%           
=======================================
  Files          19       19           
  Lines         794      796    +2     
  Branches      193      191    -2     
=======================================
+ Hits          777      779    +2     
  Misses         17       17           

โ˜” View full report in Codecov by Sentry.
๐Ÿ“ข Have feedback on the report? Share it here.

๐Ÿš€ New features to boost your workflow:
  • โ„๏ธ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • ๐Ÿ“ฆ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Introduces a test to verify that the list does not scroll when table text is dragged and dropped, ensuring onScroll is not triggered during drag-and-drop interactions.
Copy link

@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: 1

๐Ÿ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 0ce568c and bae7ddc.

๐Ÿ“’ Files selected for processing (1)
  • tests/scroll.test.js (1 hunks)

@QdabuliuQ
Copy link
Contributor Author

ๆœ‰ๆฒกๆœ‰ๅคงไฝฌreviewๅ‘€

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where text dragging in a table continues to trigger scrolling after the mouse is released. The issue occurred when users selected text, dragged it outside the table, and released the mouse - subsequent mouse movements would still cause unwanted table scrolling.

  • Adds native drag event listeners to properly reset drag state during native drag operations
  • Introduces a centralized clearDragState function to handle state cleanup consistently
  • Adds comprehensive test coverage for the text dragging scenario

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 13 comments.

File Description
src/hooks/useScrollDrag.ts Implements drag event handlers and centralizes state cleanup logic
tests/scroll.test.js Adds test case to verify scrolling doesn't occur after text drag operations

Copy link

@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: 1

๐Ÿงน Nitpick comments (3)
tests/scroll.test.js (3)

767-772: ้‡ๅค่ฐƒ็”จ selectElementText๏ผŒๆ— ๅฎž้™…ๆ„ไน‰

selectElementText ๅœจ่ฟ›ๅ…ฅ if ๅˆ†ๆ”ฏๅ‰ๅทฒๆ‰ง่กŒไธ€ๆฌก๏ผŒๅˆ†ๆ”ฏๅ†…ๅ†ๆฌก่ฐƒ็”จๅนถไธๆ”นๅ˜่กŒไธบ๏ผŒๅปบ่ฎฎๅŽป้™คไปฅ้ฟๅ…ๆททๆท†ใ€‚

-    if (targetItem && listHolder) {
-      selectElementText(targetItem);
+    if (targetItem && listHolder) {

735-735: ็”จไพ‹ๆ ‡้ข˜ๅปบ่ฎฎไปŽโ€œtableโ€ๆ”นไธบโ€œlistโ€

ๆœฌไป“ๅบ“ๅœบๆ™ฏๆ˜ฏ่™šๆ‹Ÿๅˆ—่กจ๏ผŒๆ ‡้ข˜ไธญ็š„ โ€œtableโ€ ๅฎนๆ˜“ๅผ•่ตท่ฏฏ่งฃ๏ผŒๅปบ่ฎฎๆ›ดๅ‡†็กฎ่กจ่พพใ€‚

-it('should not scroll after drop table text', () => {
+it('should not scroll after dropping selected list text', () => {

761-761: ้€‰ๆ‹ฉๅ™จไธŽๆธฒๆŸ“็ป“ๆž„็š„่€ฆๅˆๅปบ่ฎฎ้™ไฝŽ

ไธบไบ†้€‰ๆ‹ฉ็›ฎๆ ‡ๅ…ƒ็ด ๏ผŒ่ฟ™้‡Œ็ป™ li ไบบไธบๅŠ ไธŠไบ† fixed-item ็ฑปใ€‚่™ฝ็„ถ่ƒฝๅทฅไฝœ๏ผŒไฝ†ไผš่ฎฉๆต‹่ฏ•ๅฏน็ฑปๅๆœ‰ไพ่ต–ใ€‚ไนŸๅฏไปฅ็›ดๆŽฅ้€‰ๆ‹ฉ็ฌฌไธ€ไธช li ๅ…ƒ็ด ๏ผŒ่ดด่ฟ‘็œŸๅฎžๆธฒๆŸ“็ป“ๆž„๏ผŒ้™ไฝŽ่€ฆๅˆใ€‚

-        {({ id }) => <li className="fixed-item">{id}</li>}
+        {({ id }) => <li>{id}</li>}

ๅŒๆ—ถๆŠŠๅŽ็ปญๆŸฅ่ฏขๆ”นไธบ๏ผš

-    const fixedItems = container.querySelectorAll('.fixed-item');
+    const fixedItems = container.querySelectorAll('li');
๐Ÿ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

๐Ÿ’ก Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between dc9f00e and b77332d.

๐Ÿ“’ Files selected for processing (2)
  • src/hooks/useScrollDrag.ts (3 hunks)
  • tests/scroll.test.js (1 hunks)
๐Ÿšง Files skipped from review as they are similar to previous changes (1)
  • src/hooks/useScrollDrag.ts

mouseDownLock = false;
stopScroll();
};

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ๅฏๅฆ็งปๅŠจๅˆฐ onMouseUp ็š„ไฝ็ฝฎ๏ผŒๅ‡ๅฐ‘diff?

ele.ownerDocument.removeEventListener('mouseup', onMouseUp);
ele.ownerDocument.removeEventListener('mouseup', clearDragState);
ele.ownerDocument.removeEventListener('mousemove', onMouseMove);
ele.ownerDocument.removeEventListener('dragstart', clearDragState);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ๅ…ถๅฎžๅฎž็Žฐๅฐฑๆ˜ฏไธบไบ†่ฎฉ drag ็š„ๆ—ถๅ€™ๅฏไปฅๆปšๅŠจๆ‰่ฟ™ไนˆๅš็š„โ€ฆโ€ฆ

@zombieJ zombieJ merged commit 92085a0 into react-component:master Sep 10, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants