Skip to content

fix(radio): avoid hover primary color when disabled#57562

Merged
meet-student merged 7 commits intoant-design:masterfrom
yfy3939:master
Apr 6, 2026
Merged

fix(radio): avoid hover primary color when disabled#57562
meet-student merged 7 commits intoant-design:masterfrom
yfy3939:master

Conversation

@yfy3939
Copy link
Copy Markdown
Contributor

@yfy3939 yfy3939 commented Apr 3, 2026

🤔 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

Fix #57561

💡 Background and Solution

Problem:
Radio component still displays primary color border on hover when it is in disabled state, which does not meet the UI interaction specification.

Solution:
Add :not(${componentCls}-disabled) to the hover style selector in components/radio/style/index.ts to exclude disabled status, so that hover effect only works when radio is enabled.

📝 Change Log

Language Changelog
🇺🇸 English Fix Radio hover color display issue in disabled state
🇨🇳 Chinese 修复 Radio 禁用状态下 hover 仍显示主色的问题

@bolt-new-by-stackblitz
Copy link
Copy Markdown

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

Preview is ready

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

👁 Visual Regression Report for PR #57562 Failed ❌

🎯 Target branch: master (e154756)
📖 View Full Report ↗︎
📖 Alternative Report ↗︎
📊 Summary: 🔄 3 changed

Expected (Branch master) Actual (Current PR) Diff
date-picker-mode.dark.png date-picker-mode.dark.png date-picker-mode.dark.png date-picker-mode.dark.png
form-ref-item.dark.png form-ref-item.dark.png form-ref-item.dark.png form-ref-item.dark.png
rate-character-function.dark.png rate-character-function.dark.png rate-character-function.dark.png rate-character-function.dark.png

Important

There are 3 diffs found in this PR: 🔄 3 changed.
Please check all items:

  • Visual diff is acceptable

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 105f9754-6a04-432c-9c92-8166b90a9dd9

📥 Commits

Reviewing files that changed from the base of the PR and between 079dc46 and e4d04eb.

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

📝 Walkthrough

Summary by CodeRabbit

发布说明

  • Bug 修复
    • 修复了单选框在禁用状态下触发悬停时的视觉效果:禁用的单选框不再显示悬停边框颜色,悬停样式仅在可交互的单选框上生效;已选中时的悬停行为保持不变。

Walkthrough

修复 Radio 组件在禁用包装器(wrapper)处于禁用时,悬停仍应用主色边框的样式选择器,调整 hover 选择器以排除带有 -wrapper-disabled 修饰类的包装器。

Changes

Cohort / File(s) Summary
Radio 样式修复
components/radio/style/index.ts
将悬停选择器从 &:hover ${componentCls} 修改为 &:hover:not(${componentCls}-wrapper-disabled) ${componentCls},避免在带有 -wrapper-disabled 的包装器上悬停时为单选项应用主色边框。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 分钟

诗句

🐰 我在草间轻敲盘,
禁用圈圈藏灰颜,
悬停不再显主色,
小改悄然换新欢。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确简洁地总结了主要变更:修复禁用状态下的hover颜色问题,与代码改动完全相关。
Description check ✅ Passed 描述详细说明了问题、解决方案和相关改动,与changeset完全相关且信息充分。
Linked Issues check ✅ Passed 代码改动完全满足issue #57561的需求:添加:not(${componentCls}-disabled)选择器排除禁用状态下的hover样式。
Out of Scope Changes check ✅ Passed 所有改动都在scope内,仅修改了Radio组件的hover样式选择器,无关联的修改。
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.

@meet-student
Copy link
Copy Markdown
Member

Hi, 可以在 debug 的 demo 中添加一个这个场景, 方便后续的快照回归, 检测是否再次被修改异常

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 919be18c38

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread components/radio/style/index.ts Outdated

// ===================== Hover =====================
[`&:hover ${componentCls}`]: {
[`&:hover:not(${componentCls}-disabled) ${componentCls}`]: {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply disabled guard to the radio element

The new selector puts :not(${componentCls}-disabled) on the wrapper (&), but disabled state for the wrapper is ${componentCls}-wrapper-disabled while ${componentCls}-disabled is on the inner radio element. In disabled markup this condition is still true, so hovering a disabled radio still applies the primary border color and the reported bug is not actually fixed.

Useful? React with 👍 / 👎.

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 radio component hover styles to prevent them from triggering when the component is disabled. The review identifies that the current implementation incorrectly targets the wrapper class instead of the inner radio element, and provides a corrected selector to ensure proper behavior.

Comment thread components/radio/style/index.ts Outdated
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 the current code and only fix it if needed.

Inline comments:
In `@components/radio/style/index.ts`:
- Around line 259-261: The hover selector currently excludes
`${componentCls}-disabled` but the disabled class is actually
`${componentCls}-wrapper-disabled`, so update the selector in the style rule
that uses `&:hover:not(...) ${componentCls}` to exclude the wrapper disabled
class instead (i.e., use `:not(${componentCls}-wrapper-disabled)` or
`:not(.${componentCls}-wrapper-disabled)` depending on whether componentCls
includes the dot), ensuring the hover borderColor rule will not apply when
`${componentCls}-wrapper-disabled` is present.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cd99001a-3808-43c7-a1f1-d74196f061ae

📥 Commits

Reviewing files that changed from the base of the PR and between 770c522 and 919be18.

📒 Files selected for processing (1)
  • components/radio/style/index.ts

Comment thread components/radio/style/index.ts Outdated
@meet-student meet-student requested a review from zombieJ April 3, 2026 08:42
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 3, 2026

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 3, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #57562   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          810       810           
  Lines        15075     15075           
  Branches      3974      3974           
=========================================
  Hits         15075     15075           

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 3, 2026

Bundle Report

Changes will decrease total bundle size by 6.13MB (-64.51%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antd.min-array-push 3.37MB -6.13MB (-64.51%) ⬇️

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 (New) 1.88MB 1.88MB 100.0% 🚀
antd.min.js (New) 1.49MB 1.49MB 100.0% 🚀
antd-with-locales.js (Deleted) -5.06MB 0 bytes -100.0% 🗑️
antd.js (Deleted) -4.44MB 0 bytes -100.0% 🗑️

Files in antd-with-locales.min.js:

  • ./components/radio/style/index.ts → Total Size: 12.58kB

Files in antd.min.js:

  • ./components/radio/style/index.ts → Total Size: 12.58kB

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: 遇见同学 <1875694521@qq.com>
@meet-student meet-student requested a review from QDyanbing April 3, 2026 08:59
@QDyanbing
Copy link
Copy Markdown
Contributor

Hi, 可以在 debug 的 demo 中添加一个这个场景, 方便后续的快照回归, 检测是否再次被修改异常

感觉这种加了也没上用,需要hover才能触发

@meet-student
Copy link
Copy Markdown
Member

Hi, 可以在 debug 的 demo 中添加一个这个场景, 方便后续的快照回归, 检测是否再次被修改异常

感觉这种加了也没上用,需要hover才能触发

也是, 能直接 hover 吗, 模拟 也有点奇怪, 不过我看了下之前的的 issue 和 pr 很多 disabled foucs , hover 样式不对的 问题, 得想想规避归回方式

meet-student
meet-student previously approved these changes Apr 3, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 3, 2026
@QDyanbing
Copy link
Copy Markdown
Contributor

感觉还是ai之前那版好一点,不过现在这个应该也没啥问题

@meet-student meet-student merged commit a47fbbd into ant-design:master Apr 6, 2026
37 of 38 checks passed
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.

Radio 禁用时 hover 上去还会显示主色

4 participants