Skip to content

fix: ignore secondary scrollbar mouse buttons - #381

Open
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/ignore-secondary-scrollbar-buttons
Open

fix: ignore secondary scrollbar mouse buttons#381
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/ignore-secondary-scrollbar-buttons

Conversation

@nrps9909

@nrps9909 nrps9909 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • ignore non-primary mouse buttons before the scrollbar track cancels the event
  • prevent right-clicking the thumb from entering drag mode
  • preserve the existing primary-button track jump and thumb drag behavior

Problem

The track handler checked event.button only after calling preventDefault and stopPropagation, so right-click was still consumed. The thumb handler did not check the button at all, which made a right-click start a drag and disable pointer events on the list holder.

Testing

  • the new regression failed on exact base a573364: the track right-click was already defaultPrevented
  • npm test -- tests/scroll.test.js --runInBand (38 passed)
  • npm test -- --runInBand (8 suites, 281 tests passed)
  • npm run tsc
  • npm run lint (0 errors; 14 pre-existing hook warnings)
  • npm run compile (ESM, CJS, and declarations)
  • Prettier and git diff --check

Overlap audit

PR #380 adds wheel-delta tests in the same test file but does not touch the scrollbar mouse handlers. The only open PRs touching ScrollBar.tsx, #158 and #199, are conflicting branches from 2021 and 2023 covering scrollbar visibility and a broad horizontal-mode refactor; neither handles non-primary mouse buttons.

AI assistance disclosure: Codex was used to trace the scrollbar input paths, implement and validate the exact-base regression and fix, audit current open PR overlap, and draft this PR. All stated behavior and test results were verified locally.

Summary by CodeRabbit

  • Bug 修复
    • 滚动条现在会忽略右键等非主按钮操作,避免意外滚动或改变交互状态。
    • 仅在点击有效轨道或滑块区域时处理鼠标事件,提升滚动操作的准确性。

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

@nrps9909 is attempting to deploy a commit to the afc163's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a36a4dda-1946-4e57-b2cc-a5ee2a7ba1a6

📥 Commits

Reviewing files that changed from the base of the PR and between a573364 and 3dc558b.

📒 Files selected for processing (2)
  • src/ScrollBar.tsx
  • tests/scroll.test.js

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


Walkthrough

滚动条现在只处理主鼠标按钮事件。轨道和滑块会忽略右键按下,不再阻止默认行为、滚动轨道或启动拖动状态。测试覆盖轨道与滑块的右键行为。

Changes

滚动条鼠标按钮处理

Layer / File(s) Summary
过滤非主鼠标按钮事件
src/ScrollBar.tsx, tests/scroll.test.js
onContainerMouseDownonThumbMouseDown 会提前忽略非主鼠标按钮。新增测试验证右键不会调用 preventDefault、滚动轨道或设置 pointerEvents。同时简化 onScroll 调用格式。

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 3dc55

The change prevents secondary mouse buttons from consuming scrollbar events or starting thumb drags while preserving primary-button behavior. It is localized, validated by regression coverage and passing checks, and no actionable merge-blocking risk remains.

Suggested reviewers: zombiej, afc163, aojunhao123

Poem

小兔轻敲滚动条,
右键来到不响应。
轨道安静停原地,
滑块不再急着忙。
主键引路向前跑,
测试守护每一行。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要变更:忽略滚动条的非主鼠标按钮事件。标题简洁、明确,并与代码和回归测试一致。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

1 participant