Skip to content

feat: support semantic classNames and styles for clear#162

Merged
zombieJ merged 1 commit intoreact-component:masterfrom
QDyanbing:clear-semantic
Mar 17, 2026
Merged

feat: support semantic classNames and styles for clear#162
zombieJ merged 1 commit intoreact-component:masterfrom
QDyanbing:clear-semantic

Conversation

@QDyanbing
Copy link
Contributor

@QDyanbing QDyanbing commented Mar 17, 2026

背景

当前 Input 已支持 suffix 等节点的 semantic classNames / styles 定制,但 allowClear 的 clear 节点还没有对应的 semantic 能力,导致 clear 按钮只能通过外层选择器间接定制,和现有 semantic 能力不一致。

变更内容

  • 为 Input / BaseInput 增加 classNames.clear 和 styles.clear 类型定义
  • 将 classNames.clear 和 styles.clear 挂载到 clear 按钮节点
  • 按照现有 suffix 的组织方式补充测试

Summary by CodeRabbit

新功能

  • 输入组件的清除按钮现已支持自定义样式和类名配置,允许用户灵活调整清除图标的外观表现。

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

此拉取请求旨在增强 Input 组件的 allowClear 功能,使其清除按钮能够像 suffix 等其他语义化节点一样,直接通过 classNamesstyles props 进行定制。这解决了之前清除按钮只能通过外部选择器间接定制样式的问题,提升了组件样式定制的一致性和便利性。

Highlights

  • 新增语义化样式支持: 为 InputBaseInput 组件的 allowClear 按钮增加了 classNames.clearstyles.clear 的类型定义。
  • 集成样式到清除按钮: 将新增的 classNames.clearstyles.clear 属性挂载到了清除按钮节点上,使其可以直接通过 props 进行样式定制。
  • 补充测试用例: 按照现有 suffix 的组织方式,补充了相关的测试用例,以确保清除按钮的语义化样式功能正常工作。

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

Changelog
  • src/BaseInput.tsx
    • 修改了清除按钮的 className 属性,使其能够接收 classNames?.clear
    • 为清除按钮添加了 style 属性,使其能够接收 styles?.clear
  • src/interface.ts
    • CommonInputProps 接口的 classNames 属性中新增了 clear?: string
    • CommonInputProps 接口的 styles 属性中新增了 clear?: CSSProperties
  • tests/BaseInput.test.tsx
    • 更新了 BaseInput 的测试用例,添加了 allowClear 属性和 styles.clear 配置。
    • 新增了断言,验证清除按钮的 color 样式是否正确应用。
  • tests/snapshots/index.test.tsx.snap
    • 更新了快照,以反映 Input 组件在 allowClear 模式下,清除按钮应用 classNamesstyles 后的 DOM 结构变化。
  • tests/index.test.tsx
    • 更新了 Input allowClear 的测试用例,添加了 allowClear 属性以及 classNames.clearstyles.clear 配置。
    • 新增了断言,验证清除按钮的 classstyle 是否正确应用。
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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 17, 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: 9d33c348-2746-41d8-a756-5ad8e674036f

📥 Commits

Reviewing files that changed from the base of the PR and between c4b6e72 and 1fc89ae.

⛔ Files ignored due to path filters (1)
  • tests/__snapshots__/index.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (4)
  • src/BaseInput.tsx
  • src/interface.ts
  • tests/BaseInput.test.tsx
  • tests/index.test.tsx

Walkthrough

本次更改为 BaseInput 组件的清除图标按钮添加了可自定义的样式支持。通过在接口中新增 clear 属性(classNames 和 styles),允许外部通过 className 和 style props 对清除按钮进行样式定制,同时保持现有行为不变。

Changes

Cohort / File(s) Summary
接口定义
src/interface.ts
CommonInputPropsclassNamesstyles 中新增可选的 clear 属性,为清除图标元素提供样式自定义挂钩。
组件实现
src/BaseInput.tsx
清除图标按钮的 className 和 style 现已支持通过 classNames?.clearstyles?.clear 的可选属性进行定制。
单元测试
tests/BaseInput.test.tsx, tests/index.test.tsx
新增测试用例以验证清除图标的样式自定义功能,包括自定义类名和内联样式的应用。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • afc163

Poem

🐰 清晰的按钮需新装,
样式定制显优雅,
清除图标添风采,
外观自由随心变。
Props 灵活,测试完善,
小兔祝贺这改善!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and clearly describes the main change: adding support for semantic classNames and styles specifically for the clear icon element, which aligns with the changeset that adds clear properties to CommonInputProps and applies them to the clear button in BaseInput.
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
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

CodeRabbit can suggest fixes for GitHub Check annotations.

Configure the reviews.tools.github-checks setting to adjust the time to wait for GitHub Checks to complete.

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

你好,感谢你的贡献。这次的 Pull Request 为 Input 组件的清除按钮增加了 classNames.clearstyles.clear 支持,使其定制方式与其他部分(如 suffix)保持一致,提升了组件 API 的一致性和可定制性。代码变更清晰、直接,并且补充了相应的单元测试来验证新功能,快照文件也已正确更新。整体来看,这是一个不错的改进,实现方式没有问题。

@codecov
Copy link

codecov bot commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.57%. Comparing base (c4b6e72) to head (1fc89ae).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #162   +/-   ##
=======================================
  Coverage   97.57%   97.57%           
=======================================
  Files           4        4           
  Lines         206      206           
  Branches       78       80    +2     
=======================================
  Hits          201      201           
  Misses          5        5           

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

@zombieJ zombieJ merged commit af0dbc0 into react-component:master Mar 17, 2026
7 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