First keystroke doesn't register
When entering input, the first keystroke never registers and the input remains empty. Only subsequent keystrokes are counted.
Example:
- Open this fiddle (taken from another issue): https://jsfiddle.net/196e7sr9/
- Try to type in the box
You'll notice that your first keystroke isn't counted. This occurs in both Firefox and Chrome.
Of course I stumble upon the fix immediately after submitting! Here's how I fixed it:
My item object was set to an initial value of {}. It seems like the first input was actually changing input from {} to null (both of which cause my getLabel method to return ''), so I changed item to just have an initial value of null.
Simple fix, but it may be worth adding something to the README on the matter.
Same issue.
If I change item's initial value to null, as you propose, I can't reset input value (when it's just a string, and not an object).
Please add this to the tutorial, super helpful
thanks, this will be done in the next version
Thank you @kieraneglin for posting your fix for this :+1:
Wow. This was very helpful. Thank you so much. Changing the initial value to null worked for me.
https://github.com/paliari/v-autocomplete/issues/56#issuecomment-390713387
giving settimeout when clearing input @kieraneglin it will work
https://jsfiddle.net/sprabowo/196e7sr9/22/
I found that setting the initial value to null only helped the initial case. If the user types some text, selects something, then clears the text and starts typing again, they would again lose the first character.
The solution for me was to add
ref="autocomplete"
@change="onChange"
and
onChange(queryString) {
this.$nextTick(() => {
this.$refs.autocomplete.searchText = queryString;
});
},
Thank you @stevage! Your solution fixed my problem: