Skip to content

feat: unify allowClear configuration - #1257

Merged
zombieJ merged 1 commit into
react-component:masterfrom
QDyanbing:feat-unify-allow-clear
Oct 13, 2026
Merged

zombieJ merged 1 commit into
react-component:masterfrom
QDyanbing:feat-unify-allow-clear

Conversation

@QDyanbing

@QDyanbing QDyanbing commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

改动说明

接入 @rc-component/util@^1.14.0 的 useAllowClear 和 AllowClearConfig,统一 Select 的清除配置。支持 disabled 和清除按钮 tabIndex,保留自定义图标、label、各模式的清除条件和回调行为;allowClear={{ disabled: true }} 与 allowClear={false} 保持一致,并同步自定义 combobox 输入框的配置警告判断。

补充配置文档和单选、多选、tags、combobox、按钮焦点及警告行为的回归测试。

相关讨论:ant-design/ant-design#59553

验证

  • 全量测试:450 项通过,21 个快照通过。
  • TypeScript 检查、库编译及 lint 通过(存在既有 lint 警告)。
  • Chromium 验证实际布局、动态切换、焦点、Tab/Shift+Tab、鼠标点击及 Enter/Space 清除。

Summary by CodeRabbit

  • 新功能
    • allowClear 新增配置项,可禁用清除按钮、设置其 Tab 导航顺序和无障碍标签,并自定义清除图标;禁用清除按钮时,输入仍可编辑,且不再为按钮预留空间。
  • 文档
    • 补充 allowClear 配置项及其行为说明。

@vercel

vercel Bot commented Oct 13, 2026

Copy link
Copy Markdown

@QDyanbing is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1bf82d96-4283-43a7-a506-43fe27be4cab
📥 Commits

Reviewing files that changed from the base of the PR and between 59dd34a and e71eb3d.

📒 Files selected for processing (7)
  • README.md
  • package.json
  • src/BaseSelect/index.tsx
  • src/SelectInput/index.tsx
  • src/hooks/useAllowClear.tsx
  • src/utils/warningPropsUtil.ts
  • tests/allowClear.test.tsx

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

Walkthrough

本次更新使用共享的 AllowClearConfig 规范化清除配置,支持禁用清除按钮和设置按钮的 tabIndex。同时更新自定义输入警告条件,并补充文档与测试。

Changes

allowClear 配置与清除按钮

Layer / File(s) Summary
配置规范化与清除条件
package.json, src/hooks/useAllowClear.tsx, src/BaseSelect/index.tsx, src/utils/warningPropsUtil.ts, tests/allowClear.test.tsx, README.md
useAllowClear 改用 @rc-component/util 提供的配置类型和规范化逻辑。禁用配置时不显示清除按钮,也不触发相关自定义输入警告。文档和测试涵盖配置字段、清除行为及显示条件。
清除按钮 tabIndex 传递
src/BaseSelect/index.tsx, src/SelectInput/index.tsx, tests/allowClear.test.tsx
BaseSelect 将 clearTabIndex 传入 SelectInput,后者将该值设为清除按钮的 tabIndex。测试验证此设置不改变输入框的 tabIndex。

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant useAllowClear
  participant BaseSelect
  participant SelectInput
  participant ClearButton
  useAllowClear->>BaseSelect: 返回 clearTabIndex
  BaseSelect->>SelectInput: 传入 clearTabIndex
  SelectInput->>ClearButton: 设置 tabIndex
Loading

Suggested reviewers: zombiej

Merge Risk: ⚪ Minimal · up to e71eb

No actionable issue remains in the reviewed allowClear changes. The PR is mergeable after normal checks.

Pre-merge checks · Passed 4 · Failed 1

Failed 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 5 files. (2 skipped: 2 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 标题“feat: unify allowClear configuration”准确概括了本次变更的主要目标,即统一 Select 的 allowClear 配置。标题简洁且与代码、文档和测试变更一致。
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

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 5 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 timed out. The project may have too many dependencies for the sandbox.

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.

@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.46%. Comparing base (59dd34a) to head (e71eb3d).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1257      +/-   ##
==========================================
- Coverage   99.46%   99.46%   -0.01%     
==========================================
  Files          31       31              
  Lines        1307     1306       -1     
  Branches      477      457      -20     
==========================================
- Hits         1300     1299       -1     
  Misses          7        7              

☔ View full report in Codecov by Harness.
📢 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.

@zombieJ
zombieJ merged commit e5ed351 into react-component:master Oct 13, 2026
11 of 12 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

Development

Successfully merging this pull request may close these issues.

2 participants