Skip to content

fix: omit inert row click handlers - #1510

Open
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/omit-inert-row-click
Open

fix: omit inert row click handlers#1510
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/omit-inert-row-click

Conversation

@nrps9909

@nrps9909 nrps9909 commented Aug 27, 2026

Copy link
Copy Markdown

Summary

  • omit the row-level onClick prop when neither onRow.onClick nor an applicable expandRowByClick action exists
  • preserve consumer row click callbacks and expandable-row click behavior
  • add a regression that inspects the props received by a custom body-row component

Why

useRowInfo currently creates and passes an onClick function for every body row, even when that function has no possible action. Accessibility tooling and some screen readers can therefore expose ordinary table rows or their cells as clickable despite there being nothing to activate. This is the behavior reported in #1228.

The new condition removes only inert handlers. Rows still receive the composed click handler whenever a consumer supplied onRow.onClick, or when expandRowByClick applies to that row. The existing event and expansion coverage continues to pass unchanged.

On exact base 7977f2b45a501728dddf0853466c1a013a7190dc, the new regression received an onClick function for every default row and failed. It passes after this change with onClick omitted.

Fixes #1228.

Validation

  • npm test — 21 files, 237 tests
  • npm run tsc
  • npm run lint — 0 errors; 23 existing warnings
  • npx prettier --check src/hooks/useRowInfo.tsx tests/Table.spec.jsx
  • npm run compile — ESM, CJS, declarations, and Less
  • git diff --check

AI assistance disclosure: Codex was used to trace the unconditional handler, audit existing issue and PR overlap, draft the focused regression and minimal condition, and run the validation listed above. The failure and fixed behavior were verified locally against the cited exact base and PR head.

Summary by CodeRabbit

  • Bug Fixes

    • 默认情况下,表格行不再附带无效的点击处理器。
    • 保持行点击回调及可展开行的点击展开行为不变。
  • Tests

    • 新增测试,验证未配置相关行为时行不会挂载点击处理器。

@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
Contributor

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: c9c19746-695f-4593-b36e-e52d2c453d82

📥 Commits

Reviewing files that changed from the base of the PR and between 7977f2b and 7fea00f.

📒 Files selected for processing (2)
  • src/hooks/useRowInfo.tsx
  • tests/Table.spec.jsx

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


Walkthrough

本次变更使行仅在配置行点击回调或可展开行点击行为时创建 onClick。展开触发和回调顺序保持不变。新增测试验证默认行不包含 onClick

Changes

行点击行为

Layer / File(s) Summary
条件式创建与默认行为测试
src/hooks/useRowInfo.tsx, tests/Table.spec.jsx
onClick 仅在存在相关行行为时创建。满足条件时仍先触发展开,再调用行点击回调。新增测试验证默认行的 props.onClickundefined

Estimated code review effort: 1 (简单) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 7fea0

The change omits inert row click handlers while preserving configured row callbacks and expandable-row behavior. It is localized and merge-ready after normal checks, with no actionable merge-blocking risk remaining.

Suggested reviewers: zombiej

Poem

小兔检查行点击,
默认属性静悄悄。
有回调时才绑定,
可展开时先展开。
测试记录无处理器,
屏幕阅读更清楚。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了本次变更:在没有有效行为时省略无效的行点击处理器。
Linked Issues check ✅ Passed PR 实现了 Issue #1228 的核心目标:当不存在 onRow.onClick 且行不可通过 expandRowByClick 展开时,不再传递 onClick,从而避免屏幕阅读器将普通行或单元格识别为可点击。同时保留现有点击回调和可展开行行为,并新增回归测试。
Out of Scope Changes check ✅ Passed 所有变更均围绕省略无效行点击处理器及验证该行为展开。未发现与 Issue #1228 无关的代码或测试变更。
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed: private package registry requires authentication. Disable ESLint in CodeRabbit settings or use public packages.


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.

Table cells are announced as "clickable" by screen reader

1 participant