-
-
Notifications
You must be signed in to change notification settings - Fork 460
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: trigger onBlur does not require reset focused #980
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
来个测试用例 |
好了~ |
Codecov Report
@@ Coverage Diff @@
## master #980 +/- ##
=======================================
Coverage 99.78% 99.78%
=======================================
Files 38 38
Lines 1370 1373 +3
Branches 400 400
=======================================
+ Hits 1367 1370 +3
Misses 3 3
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
tests/focus.test.tsx
Outdated
fireEvent.focus(container.querySelector('input')); | ||
jest.runAllTimers(); | ||
|
||
expect(container.querySelector('.rc-select-focused')).toBeTruthy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个用例感觉不对,上一步 focus input 之后这里必然是 truthy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
最开始的 focus 有触发 onBlur
取消掉,后续重新 focus input 到这里应当是 truthy。这个问题是由于 disabled 重置了 focused 导致无法再次触发 focus,所以这里逻辑应该没问题。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉上应该是判断 onFocus
事件有没有触发?focus 状态是有的,但是原问题是内部的 focus 状态错误地保留了导致没有触发 foucs 事件。
close ant-design/ant-design#44619
问题出现原因:在
Select
触发onBlur
后其disabled
为 true 时触发了重置 focused 的操作,将onBlur
要执行的回调给清除掉了。