-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Autocomplete: add clearable prop #12171
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
Autocomplete: add clearable prop #12171
Conversation
Deploy preview for element ready! Built with commit 88ff1b7 |
@arthurdenner it seems that you only add |
@arthurdenner after I click the clear icon, the autocomplete suggestions are expected to display all. |
Sorry @ziyoung, I didn't notice this. Thanks for pointing it out. I did a little digging, tried a few things, but only got it fixed by adding handleClear() {
this.$nextTick(_ => {
this.handleFocus();
});
}, However, I'm not sure if that's the best solution so I didn't commit it. Would you accept this as a solution or do you have an idea of how to fix it properly? |
My recommendation is "try to avoid $nextTick / setImmediate / setTimeout", they could cause timing issues, and they don't offer a clear picture of function call stack and state transition. |
Thanks, @wacky6. I'm aware of that, which is why I'm not satisfied with this fix. But what I noticed is: though Do you have a suggestion to a proper fix? |
Why not just call auto-complete's You might also need to consider emission of 'focus' event. Personally, I don't think clearing auto-complete should emit another focus event. |
Good point, it shouldn't emit another focus event. Calling |
I've looked at the source code, the problem is more serious than I thought.
For reference, input's clearable was added in #8509 (community contribution) Consider:
|
@wacky6, just so you know, I've implemented the more complete fix but I'm waiting for the fixes you proposed to be reviewed. If you think this could be a breaking change, I can change the pull request to the |
hope this will soon be released ! |
@wacky6, I committed the more complete fix and changed the PR to the |
LGTM for next. Should add some tests afterwards. jsfiddle playground: https://jsfiddle.net/zd6gfbn1/ |
f6f51ae
to
ef33295
Compare
Sorry for bothering, but what is missing for this PR to be accepted? 😕 |
@jikkai This PR can be merged for 3.0 milestone |
Hi guys, any updates about this PR? I'm about to launch a product and I would like to have this feature. :/ |
@ziyoung Should this PR go to 2.0 or 3.0? |
@arthurdenner clear event is added in pr #13326. I didn't notice there was a bug. It's my fault. |
0890304
to
88ff1b7
Compare
@ziyoung I've rebased the branch and the PR points to the |
@arthurdenner done.😄 |
Thank you very much, @ziyoung! |
* Autocomplete: add clearable prop * Input: remove focus after clearing the value * Autocomplete: hide options after clearing the value
Please make sure these boxes are checked before submitting your PR, thank you!
dev
branch.This PR allows
el-autocomplete
to be clearable, just likeel-input
.