-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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): [input] lose focus when click suffix icon #13264
Conversation
🧪 Playground Preview: https://element-plus.run/?pr=13264 |
Looks like this is adding This is potential problem for accessibility and tests that use |
The I do not think this will cause accessibility issues, but I am really sorry for the testing and I have not thought of any other alternative methods at the moment. |
…lus#13264) * feat(hooks): add useFocusController * fix(components): [input] lose focus when click suffix icon closed element-plus#13153, element-plus#13159 * refactor(hooks): use-focus-controller * test: fix test * test: update * fix(theme-chalk): [input] add cursor style to the wrapper
fix #13153, close #13159
When click on the prefix or suffix icon, it causes the input to lose focus and then regain focus, resulting in unnecessary loss of focus behavior, This PR has corrected this behavior.
before
after
Please make sure these boxes are checked before submitting your PR, thank you!
dev
branch.Description
🤖 Generated by Copilot at 7b9db8c
This pull request introduces a new
useFocusController
hook that simplifies the focus and blur logic of input components. It also updates the tests and the implementation of theinput
,input-number
, andselect
components to use this hook. The hook avoids unnecessary blur events when clicking on prefix or suffix elements and provides callbacks for custom focus and blur actions.Related Issue
Fixes #___.
Explanation of Changes
🤖 Generated by Copilot at 7b9db8c
useFocusController
hook to handle focus and blur events of input elements (link, link, link, link, link, link)input.vue
withuseFocusController
hook (link, link)@element-plus/hooks
module (link)wrapperRef
is bound to thediv
element with thewrapperKls
class using theref
attribute (link)triggerAttrs
are bound to thespan
element with thensInput.e('suffix-inner')
class using thev-bind
directive (link)sleep
calls toinput-number.test.tsx
andinput.test.tsx
to wait for asynchronous updates and events (link, link, link, link)sleep
call inselect.test.ts
to ensureblur
event is emitted (link)