Skip to content

fix(Input.Password): respect controlled visibility state - #59168

Merged
MadCcc merged 1 commit into
masterfrom
fix-input-password-controlled
Sep 2, 2026
Merged

MadCcc merged 1 commit into
masterfrom
fix-input-password-controlled

Conversation

@QDyanbing

Copy link
Copy Markdown
Member

English Template / 英文模板

🤔 这个变动的性质是?

  • 🆕 新特性提交
  • 🐞 Bug 修复
  • 📝 站点、文档改进
  • 📽️ 演示代码改进
  • 💄 组件样式/交互改进
  • 🤖 TypeScript 定义更新
  • 📦 包体积优化
  • ⚡️ 性能优化
  • ⭐️ 功能增强
  • 🌐 国际化改进
  • 🛠 重构
  • 🎨 代码风格优化
  • ✅ 测试用例
  • 🔀 分支合并
  • ⏩ 工作流程
  • ⌨️ 无障碍改进
  • ❓ 其他改动(是关于什么的改动?)

🔗 相关 Issue

fix #59167

💡 需求背景和解决方案

Input.Password 使用 visibilityToggle.visible 受控显隐状态时,点击显隐图标仍会更新组件内部状态,导致密码在受控值保持 false 时也被显示。

受控模式下不再更新内部显隐状态,仅触发 onVisibleChange 通知外部更新;非受控模式保持原有行为。同时补充回归测试,确保点击图标不会绕过受控值。

📝 更新日志

语言 更新描述
🇺🇸 英文 🐞 Fix Input.Password ignoring the controlled visibility state when clicking the visibility toggle.
🇨🇳 中文 🐞 修复 Input.Password 点击显隐按钮时未遵循受控显隐状态的问题。

@bolt-new-by-stackblitz

Copy link
Copy Markdown

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

@github-actions

github-actions Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Preview is ready

@github-actions

github-actions Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

👁 Visual Regression Report for PR #59168 Passed ✅

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

🎊 Congrats! No visual-regression diff found.

📖 中文报告

👁 PR #59168 视觉回归报告 通过 ✅

🎯 目标分支: master (c99d71d)

🎊 恭喜!未发现视觉回归差异。

@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 69097c44-fea8-406d-9ced-28a082ae0a58

📥 Commits

Reviewing files that changed from the base of the PR and between c99d71d and 16e6660.

📒 Files selected for processing (2)
  • components/input/Password.tsx
  • components/input/__tests__/Password.test.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • 修复受控模式下密码可见性状态被组件内部意外修改的问题。
    • 现在密码可见性完全由外部状态控制,切换操作仍会正确触发变更回调。
  • Tests

    • 新增受控模式下密码可见性保持不变的测试覆盖。

Walkthrough

受控模式下,Input.Password 不再直接更新内部可见性状态。新增测试验证点击图标后密码仍保持隐藏,并正确触发回调。

Changes

密码可见性控制

Layer / File(s) Summary
受控可见性与测试
components/input/Password.tsx, components/input/__tests__/Password.test.tsx
受控模式下跳过内部 setVisible,由 visibilityToggle.onVisibleChange 驱动状态。新增测试验证密码类型保持为 password,且回调收到 true。

Estimated code review effort: 2 (简单) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 16e66

This change keeps password visibility under the parent-controlled state while preserving uncontrolled behavior and the existing callback contract. No actionable merge-blocking risk remains after normal checks and review.

Poem

小兔看到密码眼,
受控状态稳稳站。
点击回调传出声,
密码仍藏不露脸。
测试守住安全门。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题明确说明修复 Input.Password 受控显隐状态未生效的问题,与主要代码变更一致。
Description check ✅ Passed 描述说明了受控模式下的缺陷、修复方案和回归测试,与变更内容一致。
Linked Issues check ✅ Passed 代码在受控模式下不再更新内部显隐状态,并新增测试验证 visibilityToggle.visible 为 false 时密码仍保持隐藏,满足问题 #59167 的目标。
Out of Scope Changes check ✅ Passed 变更仅涉及 Input.Password 的受控显隐逻辑和对应回归测试,未发现与问题目标无关的代码变更。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-input-password-controlled

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.

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
dist/antd.min.js 439.43 KB (+1 B 🔺)
dist/antd-with-locales.min.js 522.78 KB (+3 B 🔺)

@codecov

codecov Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Bundle Report

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

Detailed changes
Bundle name Size Change
antd.min-array-push 3.22MB 6 bytes (0.0%) ⬆️

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 3 bytes 1.79MB 0.0%
antd.min.js 3 bytes 1.43MB 0.0%

@pkg-pr-new

pkg-pr-new Bot commented Aug 31, 2026

Copy link
Copy Markdown
More templates

npm i https://pkg.pr.new/antd@59168

commit: 16e6660

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c99d71d) to head (16e6660).

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #59168   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          834       834           
  Lines        15994     15995    +1     
  Branches      4204      4205    +1     
=========================================
+ Hits         15994     15995    +1     

☔ View full report in Codecov by Harness.
📢 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.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying ant-design with  Cloudflare Pages  Cloudflare Pages

Latest commit: 16e6660
Status: ✅  Deploy successful!
Preview URL: https://6f20aa37.ant-design.pages.dev
Branch Preview URL: https://fix-input-password-controlle.ant-design.pages.dev

View logs

@nrps9909 nrps9909 left a comment

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.

Reviewed exact head 16e6660c330abc4eadbee80b20eccc02c0b82982.

The regression is causal: applying only the submitted test to base c99d71d06c fails because the controlled-false input changes to type="text"; the exact head keeps the input controlled while still emitting onVisibleChange(true). I also ran an independent matrix covering controlled true and false, keyboard activation/callback direction, and transition back to uncontrolled behavior. The focused run passed 27 tests including that temporary probe and 5 snapshots; ESLint, Biome, git diff --check, and all current substantive remote checks are green. The temporary probe was removed and the exact-head worktree is clean.

AI assistance disclosure: Codex was used to inspect the controlled-state path, run the base-vs-head reproduction, author the temporary boundary probe, and draft this review. I independently verified the exact head and results.

@MadCcc
MadCcc merged commit d082122 into master Sep 2, 2026
52 checks passed
@MadCcc
MadCcc deleted the fix-input-password-controlled branch September 2, 2026 08:09
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.Password 的visibilityToggle.visible设置为false还是能通过点击图标显示密码

3 participants