Skip to content

fix: remove button semantics when click upload is disabled - #728

Open
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/open-file-dialog-role
Open

fix: remove button semantics when click upload is disabled#728
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/open-file-dialog-role

Conversation

@nrps9909

@nrps9909 nrps9909 commented Aug 26, 2026

Copy link
Copy Markdown

Summary

  • remove role="button" when openFileDialogOnClick={false}
  • remove the wrapper from sequential keyboard focus in the same state
  • add regression coverage for both semantics

When click upload is disabled, rc-upload already replaces its click and key handlers with no-ops. Keeping button semantics and tabIndex=0 therefore exposes a focusable control that cannot be activated. Drag-and-drop behavior remains unchanged.

Closes #294.

Verification

  • Exact-base regression: 57 passed, 1 failed because the wrapper still had tabIndex=0
  • Fixed full suite: 2 suites, 58 tests passed
  • npm run tsc
  • npm run lint — 0 errors, 8 pre-existing unused-disable warnings
  • npm run compile — ESM, CJS, and declarations passed
  • prettier --check src/AjaxUploader.tsx tests/uploader.spec.tsx
  • git diff --check

I checked all current open PR titles and changed files before implementation. Several older PRs touch AjaxUploader.tsx, but none addresses the openFileDialogOnClick={false} button semantics.

AI assistance disclosure: Codex was used to trace the current render contract, audit open-PR overlap, add the focused regression, and run verification. The exact-base failure and final diff were reviewed locally.

Summary by CodeRabbit

  • Bug Fixes

    • 修复上传控件在禁用点击打开文件对话框时仍可聚焦并被识别为按钮的问题。
    • 提升键盘导航和辅助功能行为的一致性。
  • Tests

    • 新增测试,验证禁用点击打开功能后,控件不可聚焦且不具有按钮角色。

@vercel

vercel Bot commented Aug 26, 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 26, 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: 645238b5-e483-4890-8dbc-6f63bbd2f3c7

📥 Commits

Reviewing files that changed from the base of the PR and between 9aba193 and 71e6d72.

📒 Files selected for processing (2)
  • src/AjaxUploader.tsx
  • tests/uploader.spec.tsx

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


Walkthrough

openFileDialogOnClickfalse 时,上传控件不再设置 tabIndex="0"role="button"。测试新增了对这两个属性的验证。

Changes

上传控件可访问性属性

Layer / File(s) Summary
同步属性逻辑与测试
src/AjaxUploader.tsx, tests/uploader.spec.tsx
hasControlInside 为真或 openFileDialogOnClick 为假时,组件移除 tabIndexrole="button"。新增测试验证 openFileDialogOnClick={false} 时的属性值。

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

Merge Risk: ⚪ Minimal · up to 71e6d

This change removes misleading button semantics and keyboard focus when click-to-upload is disabled while preserving drag-and-drop behavior. No actionable merge-blocking risk remains after the reported verification checks.

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 标题准确概括了主要变更:当 openFileDialogOnClick 为 false 时,移除上传控件的按钮语义。
Linked Issues check ✅ Passed 变更满足 Issue #294。openFileDialogOnClick 为 false 时,组件不再设置 role="button",也不再提供顺序键盘焦点。新增测试覆盖这两个行为。
Out of Scope Changes check ✅ Passed 所有变更均围绕 Issue #294。实现修改和回归测试没有发现无关代码或超出范围的变更。
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…
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.

openFileDialogOnClick为 false 时,role 依然为 button

1 participant