-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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(components): [select] optimize the triggering of blur event #11524
Conversation
🧪 Playground Preview: https://element-plus.run/?pr=11524 |
The drop-down box pops up again when it is closed. |
#10893 的问题还在 |
代码从fix/select-blur分支迁出,App.vue用的#10893 中的demo。 2023-02-13.20-11-34.mp4chrome的效果 因为只是弹出一下后消失,因此放慢了动画。 2023-02-13.20-13-16.mp4 |
不是ElMessageBox中ElFocusTrap的问题,我直接把ElMessageBox中的ElFocusTrap去掉,用js代码手动把焦点导到ElMessageBox的按钮上,点击OK按钮后ElSelect还是弹出来了。 |
chrome 这样是符合设计的 我 Safari 也复现了火狐的问题,弹窗没有被关闭。 简单排查了下,像是 button 无法被聚焦引起的,原生 button Safari 都没有聚焦。 麻烦你测试下火狐是不是也是这种情况(点页面空白处,然后使用 Tab 按键) |
2023-02-13.21-09-35.mp4这样吗?看着好像没啥问题,按钮都能聚集啊! |
https://github.com/element-plus/element-plus/blob/dev/packages/components/message-box/src/index.vue#L476 |
chrome 都成功了。可能是使用了具有差异浏览器api? |
我测了下chrome在visibility: hidden;会触发blur,但firefox不会,会不会是这个原因? |
这应该是 FocusTrap 的问题。从2.2.18后,当使用鼠标关闭 Dialog、Drawer 弹窗时,焦点将无法返回之前的按钮。 另外我觉得应该由 FocusTrap 控制焦点更合理 |
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.
LGTM
…ent-plus#11524) * fix(components): [select] drop-down selection is not closed when blur closed element-plus#10893, element-plus#10992 * fix(components): [select] optimize the triggering of blur event * refactor(components): [select] optimize code
fix #10893, fix #10717, closed #10992
Please make sure these boxes are checked before submitting your PR, thank you!
dev
branch.At present, the handleBlur function determines whether to trigger the blur event through isSilentBlur, and the isSilentBlur is modified by clicking Option to trigger the handleOptionSelect function.
However, the handleOptionSelect function is triggered later than the handleBlur function, the blur event may be triggered incorrectly.
This PR modified to: After the focus transferred from input, judge whether it is in the drop-down selection. same PR #10091
before
after