New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix:Input-Password onVisibleChange #46558
Fix:Input-Password onVisibleChange #46558
Conversation
Run & review this pull request in StackBlitz Codeflow. |
onChange 不应该监听 value 本身,会形成死循环 |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit c962526:
|
我的理解这不应该是用户需要关注的点吗? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #46558 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 708 708
Lines 12120 12121 +1
Branches 3217 3217
=========================================
+ Hits 12120 12121 +1 ☔ View full report in Codecov by Sentry. |
不是符合语义的问题,所有 onChange 方法都应该由内部逻辑触发,而不是监听受控属性变化 |
已修改。 |
你可以试试 如果控制 value 也会触发 onChange,就死循环了。 |
[中文版模板 / Chinese template]
🤔 This is a ...
🔗 Related issue link
💡 Background and solution
问题:input.password 在 由 icon 控制时 onVisibleChange 回调会被触发,而由外部控件控制visible 时,不会触发回调。
复现链接
解决办法:
使用useEffect 在当 visbleChange 后 回调函数,符合语义
📝 Changelog
我的理解onVisibleChange 回调 本来就不应该在“onVisibleChange” 点击事件处理函数里调用,
源码里的“onVisibleChange” 函数是 icon 的点击处理
☑️ Self-Check before Merge