Skip to content

fix: remove tabIndex={-1} from clear button to make it keyboard accessible#168

Open
cyphercodes wants to merge 1 commit intoreact-component:masterfrom
cyphercodes:fix-clear-button-accessibility
Open

fix: remove tabIndex={-1} from clear button to make it keyboard accessible#168
cyphercodes wants to merge 1 commit intoreact-component:masterfrom
cyphercodes:fix-clear-button-accessibility

Conversation

@cyphercodes
Copy link

@cyphercodes cyphercodes commented Mar 25, 2026

This PR removes the tabIndex={-1} from the clear button in BaseInput component.

Problem

The clear button had tabIndex={-1} which made it unreachable via keyboard navigation. This violates WCAG 2.1 success criteria 2.1.1 (Keyboard) and 2.1.3 (Keyboard No Exception), creating inequality for keyboard users who cannot access and operate this functionality.

Solution

Remove the tabIndex={-1} attribute so the clear button becomes focusable by default. This allows keyboard users to tab to the clear button and activate it.

Related Issue

Fixes ant-design/ant-design#57378

Note

After this change, ant-design will need to add proper :focus styles for the clear button in their style file (components/input/style/index.ts - genAllowClearStyle function) to ensure the focus state is visually identifiable.

Summary by CodeRabbit

发布说明

  • Bug Fixes
    • 改进了输入框清除按钮的键盘无障碍支持。清除按钮现已包含在标准键盘 Tab 导航顺序中,使用键盘导航的用户现可直接访问和使用该按钮。

…sible

The clear button had tabIndex={-1} which made it unreachable via keyboard
navigation, violating WCAG 2.1 success criteria 2.1.1 and 2.1.3.

This change makes the clear button focusable so keyboard users can
access and operate this functionality.

Fixes ant-design/ant-design#57378
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the keyboard accessibility of the clear button within the BaseInput component. By removing a specific HTML attribute, the button becomes fully navigable and operable for users relying on keyboard input, thereby improving compliance with web accessibility standards and ensuring a more inclusive user experience.

Highlights

  • Accessibility Improvement: Removed tabIndex={-1} from the clear button in the BaseInput component to make it keyboard accessible, addressing WCAG 2.1 success criteria 2.1.1 and 2.1.3.
  • Keyboard Navigation: The clear button is now focusable by default, allowing keyboard users to tab to it and activate its functionality.
  • Future Styling Note: Noted that ant-design will need to add proper :focus styles for the clear button in their style file to ensure visual identification of the focus state.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Mar 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 431d85c9-cdf7-4b8c-973c-e69581d0766d

📥 Commits

Reviewing files that changed from the base of the PR and between 5d1a32d and e8edef9.

📒 Files selected for processing (1)
  • src/BaseInput.tsx
💤 Files with no reviewable changes (1)
  • src/BaseInput.tsx

走查

BaseInput.tsx 的清除按钮中移除 tabIndex={-1} 属性,使其恢复至正常标签顺序中,改善了键盘用户的可访问性,符合 WCAG 2.1.1 和 2.1.3 标准。

更改

队列 / 文件 摘要
清除按钮可访问性修复
src/BaseInput.tsx
移除清除按钮上的 tabIndex={-1} 属性,允许键盘用户通过 Tab 键聚焦并操作此元素。

代码审查工作量

🎯 1 (平凡) | ⏱️ ~3 分钟

可能相关的 PR

建议的审查者

  • afc163

诗歌

🐰 小兔按下 Tab 键,清除按钮亮堂堂,
无需隐藏在暗处,焦点如影随风扬,
无障碍的世界里,每只爪子都能闪闪发光~✨

🚥 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 标题准确总结了主要变更:从清除按钮中移除 tabIndex={-1} 以提高键盘可访问性。
Linked Issues check ✅ Passed 代码变更完全满足 #57378 的核心需求:移除 tabIndex={-1} 使清除按钮可通过键盘导航获得焦点。
Out of Scope Changes check ✅ Passed 拉取请求仅包含一行删除,范围完全在解决可访问性问题的预期内。
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

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.

Copy link
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 removes the tabIndex={-1} attribute from the clear icon button in src/BaseInput.tsx. There are no review comments to provide feedback on.

@afc163
Copy link
Member

afc163 commented Mar 25, 2026

图片

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.

Input: clear button is not accessible

2 participants