Skip to content

fix(Button): incorrect hover color for default solid button#55825

Merged
afc163 merged 3 commits intoant-design:masterfrom
andriib-ship-it:fix/button-hover-color
Nov 24, 2025
Merged

fix(Button): incorrect hover color for default solid button#55825
afc163 merged 3 commits intoant-design:masterfrom
andriib-ship-it:fix/button-hover-color

Conversation

@andriib-ship-it
Copy link
Contributor

中文版模板 / Chinese template

🤔 This is a ...

  • 🆕 New feature
  • 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ⌨️ Accessibility improvement
  • ❓ Other (about what?)

🔗 Related Issues

💡 Background and Solution

  • The specific problem to be addressed.
  • List the final API implementation and usage if needed.
  • If there are UI/interaction changes, consider providing screenshots or GIFs.

📝 Change Log

Language Changelog
🇺🇸 English Fix: Incorrect hover and active colors for a button with color="default" and variant="solid" props.
🇨🇳 Chinese

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 23, 2025

👁 Visual Regression Report for PR #55825 Passed ✅

🎯 Target branch: master (3de02ee)
📖 View Full Report ↗︎
📖 Alternative Report ↗︎

🎊 Congrats! No visual-regression diff found.

@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor

github-actions bot commented Nov 23, 2025

Preview is ready

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @andriib-ship-it, 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 resolves a visual bug affecting the default solid button component. The change ensures that the text color for these buttons is correctly applied during hover and active states, providing a consistent and intended user interface experience.

Highlights

  • Button Styling Fix: Corrected the hover and active state text colors for default solid buttons. Previously, these states were not consistently applying the intended solidTextColor token, leading to an incorrect visual appearance.
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
Contributor

coderabbitai bot commented Nov 23, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Summary by CodeRabbit

发布说明

  • 样式
    • 优化了按钮solid变体在悬停和活动状态下的文本颜色显示,使其与基础文本颜色保持一致。

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

修复按钮实心(solid)变体的样式生成逻辑:在 genVariantStyle 中为 solid 的默认颜色段新增并设置了 text-color-hovertext-color-active,其值指向基础 text-color(通过 var(--text-color)),以保证 hover/active 时文字颜色与基色一致。

Changes

变更组 / 文件 变更摘要
按钮样式变量修复
components/button/style/variant.ts
genVariantStyle 的 solid 变体默认色分支中,新增 text-color-hovertext-color-active CSS 变量并将其赋值为 var(--text-color)(与基础 text-color 保持一致),修复 hover/active 状态文字颜色不正确的问题。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • 变更集中于单个样式文件,修改为一致的 CSS 变量映射,逻辑简单但影响渲染结果。
  • 复核要点:
    • components/button/style/variant.ts 中变量名和作用域是否正确(--text-color-hover/--text-color-active 与已有变量命名一致)。
    • 确认该赋值不会意外影响其他变体或主题色的预期覆盖逻辑。
    • 检查默认颜色(default)和自定义颜色在不同主题下的表现是否符合预期。

Poem

🐰 一只兔子的庆祝诗

按钮静时色已安,
悬停活跃也相伴,
变量指向一处光,
小改一行大不同,
前端样式乐开颜 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题清晰准确地描述了此拉取请求的主要修复内容:按钮default solid变体的悬停颜色问题。
Description check ✅ Passed 描述通过变更日志明确表述了修复目标:解决color="default"和variant="solid"按钮的悬停和活跃颜色不正确的问题。
Linked Issues check ✅ Passed 代码修改通过在solid变体的text-color-hover和text-color-active设置中添加CSS变量映射,完全满足了#55822中恢复按钮悬停文本颜色为白色的需求。
Out of Scope Changes check ✅ Passed 所有修改仅限于components/button/style/variant.ts中的solid变体样式,直接针对链接问题中报告的悬停颜色问题,没有范围外的更改。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 731c99e and b1fbfe0.

📒 Files selected for processing (1)
  • components/button/style/variant.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/button/style/variant.ts

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 correctly fixes an issue where the hover and active text colors for a default solid button were incorrect. The change ensures the text color remains consistent across different states by using token.solidTextColor for all of them. The fix is correct and addresses the bug. I have one minor suggestion to improve code maintainability.

Comment on lines +212 to +213
[getCssVar('text-color-hover')]: token.solidTextColor,
[getCssVar('text-color-active')]: token.solidTextColor,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While this is correct, to improve maintainability and reduce repetition, you could consider using the text-color CSS variable for the hover and active states. This ensures that if text-color is ever changed, the hover and active states will automatically update with it.

Suggested change
[getCssVar('text-color-hover')]: token.solidTextColor,
[getCssVar('text-color-active')]: token.solidTextColor,
[getCssVar('text-color-hover')]: `var(${getCssVar('text-color')})`,
[getCssVar('text-color-active')]: `var(${getCssVar('text-color')})`,

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 23, 2025

@codecov
Copy link

codecov bot commented Nov 23, 2025

Bundle Report

Changes will increase total bundle size by 202 bytes (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antd.min-array-push 3.91MB 202 bytes (0.01%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: antd.min-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
antd-with-locales.min.js 101 bytes 2.15MB 0.0%
antd.min.js 101 bytes 1.76MB 0.01%

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 24, 2025
@afc163 afc163 merged commit ef52e15 into ant-design:master Nov 24, 2025
37 checks passed
@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (3de02ee) to head (a0c6620).
⚠️ Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #55825   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          803       803           
  Lines        14804     14804           
  Branches      3913      3913           
=========================================
  Hits         14804     14804           

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

@github-actions
Copy link
Contributor

🎉 Thank you for your contribution! If you have not yet joined our DingTalk community group, please feel free to join us (when joining, please provide the link to this PR).

🎉 感谢您的贡献!如果您还没有加入钉钉社区群,请扫描下方二维码加入我们(加群时请提供此 PR 链接)。

钉钉社区群二维码

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect hover color for button

3 participants