Skip to content

fix: render select input as text combobox#1222

Open
QDyanbing wants to merge 1 commit intoreact-component:masterfrom
QDyanbing:fix-select-input-type-text
Open

fix: render select input as text combobox#1222
QDyanbing wants to merge 1 commit intoreact-component:masterfrom
QDyanbing:fix-select-input-type-text

Conversation

@QDyanbing
Copy link
Copy Markdown
Contributor

@QDyanbing QDyanbing commented May 10, 2026

What changed

  • Render the internal Select input as type="text" instead of type="search" so it can validly carry role="combobox".
  • Default the internal input autocomplete value to new-password to preserve the Chromium autocomplete workaround that originally motivated type="search".
  • Update accessibility coverage and snapshots for the new markup.

Why

input type="search" without a native list attribute has an implicit searchbox role in ARIA in HTML, so overriding it with role="combobox" creates invalid markup. A text input allows the combobox role while autocomplete="new-password" keeps browser autocomplete suppressed.

Fixes ant-design/ant-design#57904.

Validation

  • npx rc-test --updateSnapshot --runInBand
  • npm run tsc

Summary by CodeRabbit

变更说明

  • Bug 修复
    • 调整了 Select 组件搜索输入框的默认行为,优化了浏览器自动完成功能的处理方式,提高了输入类型的一致性,确保更好的用户体验和跨浏览器兼容性。

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 10, 2026

@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
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 10, 2026

概览

该 PR 修复了 Select 组件的 ARIA-in-HTML 规范合规问题。将内部输入的 type 从动态值改为硬编码的 'text',将默认 autoComplete 从 'off' 改为 'new-password',并更新相应测试以验证这些行为变化。

变更内容

ARIA 合规性修复

层级 / 文件 摘要
输入实现修改
src/SelectInput/Input.tsx
输入 type 属性硬编码为 'text'(替代之前的模式依赖值),默认 autoComplete 值从 'off' 改为 'new-password'。
可访问性测试
tests/Accessibility.test.tsx
在默认 ARIA 测试中添加断言,验证内部输入的 type 为 "text" 且不存在 list 属性。
Select 测试
tests/Select.test.tsx
更新搜索输入类型测试,验证启用搜索且下拉框打开时,输入使用 type="text" 和 autocomplete="new-password"。

预期代码审查工作量

🎯 2 (简单) | ⏱️ ~10 分钟

可能相关的 PR

建议审查者

  • afc163
  • zombieJ

庆祝之诗 🐰

小兔跳啊跳,修好了问题妙,
type="text" 换上身,role="combobox" 不再凶,
ARIA 规范都满足,autocomplete 新密码,
测试检验真牢靠,合规之路终完成! ✨

🚥 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 PR 标题准确反映了主要变更:将 Select 的内部输入从 type="search" 改为 type="text" 以支持有效的 combobox 角色。
Linked Issues check ✅ Passed 代码变更完全满足 issue #57904 的要求:将输入改为 type="text",保持 role="combobox",添加 autocomplete="new-password" 以抑制浏览器自动完成。
Out of Scope Changes check ✅ Passed 所有变更都与解决 ARIA-in-HTML 无效标记问题相关,无超出范围的变更。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.44%. Comparing base (740b93b) to head (6b3050f).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1222      +/-   ##
==========================================
- Coverage   99.44%   99.44%   -0.01%     
==========================================
  Files          31       31              
  Lines        1256     1255       -1     
  Branches      437      458      +21     
==========================================
- Hits         1249     1248       -1     
  Misses          7        7              

☔ 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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Select component's input element by changing its type from search to text and its default autoComplete value from off to new-password. These changes are reflected across the component's implementation, accessibility tests, and various snapshots to ensure consistent behavior and prevent browser-level autocomplete interference. I have no feedback to provide as there were no review comments.

@QDyanbing QDyanbing marked this pull request as ready for review May 10, 2026 07:54
Copy link
Copy Markdown
Contributor

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/SelectInput/Input.tsx`:
- Line 174: The autoComplete fallback uses logical OR which treats an explicit
empty string as falsy; update the assignment in Input.tsx (the autoComplete
property where it currently reads autoComplete: autoComplete || 'new-password')
to use the nullish coalescing operator so that only null or undefined trigger
the default (i.e., replace the `||` fallback with `??` for the autoComplete
property in the SelectInput/Input component).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 694f759d-0632-42e2-a47c-d07d9e0fdaf2

📥 Commits

Reviewing files that changed from the base of the PR and between 740b93b and 6b3050f.

⛔ Files ignored due to path filters (4)
  • tests/__snapshots__/Combobox.test.tsx.snap is excluded by !**/*.snap
  • tests/__snapshots__/Select.test.tsx.snap is excluded by !**/*.snap
  • tests/__snapshots__/Tags.test.tsx.snap is excluded by !**/*.snap
  • tests/__snapshots__/ssr.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (3)
  • src/SelectInput/Input.tsx
  • tests/Accessibility.test.tsx
  • tests/Select.test.tsx

Comment thread src/SelectInput/Input.tsx
} as React.CSSProperties,
autoFocus,
autoComplete: autoComplete || 'off',
autoComplete: autoComplete || 'new-password',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

避免用 || 覆盖显式空字符串的 autoComplete

Line 174 建议改为 ??。当前写法会把调用方传入的 "" 覆盖为 'new-password',行为不够精确。

🔧 建议修改
-    autoComplete: autoComplete || 'new-password',
+    autoComplete: autoComplete ?? 'new-password',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
autoComplete: autoComplete || 'new-password',
autoComplete: autoComplete ?? 'new-password',
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/SelectInput/Input.tsx` at line 174, The autoComplete fallback uses
logical OR which treats an explicit empty string as falsy; update the assignment
in Input.tsx (the autoComplete property where it currently reads autoComplete:
autoComplete || 'new-password') to use the nullish coalescing operator so that
only null or undefined trigger the default (i.e., replace the `||` fallback with
`??` for the autoComplete property in the SelectInput/Input component).

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.

Select renders invalid ARIA-in-HTML markup: input type="search" with role="combobox" and no list

1 participant