v-autocomplete icon indicating copy to clipboard operation
v-autocomplete copied to clipboard

Input deleted after having one item selected

Open kno opened this issue 7 years ago • 6 comments

You can see this behaviour in the DEMO. It starts with one item selected. If you want to add any character, the input is deleted. this happens every time you have one item selected. I your code starts with empty item, the first character is ignored.

kno avatar Jul 14 '18 15:07 kno

I have the same issue; I get the initial list from an API call, set the selected item but when I want to change the value, the first characters get deleted.

on my getLabel method I have return item ? item.value : '';

If I only put return item.value; it throws an error

Error in callback for watcher "value": "TypeError: Cannot read property 'value' of null"

found in

---> <VAutocomplete>

Please some feedback @paliari :D

krugerdavid avatar Jul 26 '18 20:07 krugerdavid

If anyone has any solution to this please update,i'm also facing same issue.

@paliari Please help

Garima avatar Aug 07 '18 07:08 Garima

Set item: null, not false or {}

RomkaLTU avatar Feb 12 '19 12:02 RomkaLTU

I am facing this same issue - setting the item to null didn't affect anything. It seems the author has abandoned this project.

UPDATE: What RomkaLTU was trying to say is that the object you bind to the control - what you set in the v-model attribute - that must be set to null in the data function of vue. This is because of how the first input change is handled. So to fix this, if your code is below it will work:

<v-autocomplete v-model="MyItem"></v-autocomplete>
data() {
   return {
       MyItem: null
     }
  }

dstrohschein avatar Feb 19 '20 21:02 dstrohschein

I am facing this same issue, you need to change the code like below

....
getLabel (item) {
    return item == null ? '' : item.email;
},
....

it's work for me

andhikayuana avatar Feb 21 '20 09:02 andhikayuana

You can see this behaviour in the DEMO. It starts with one item selected. If you want to add any character, the input is deleted. this happens every time you have one item selected. I your code starts with empty item, the first character is ignored.

I think the reason is that when the v model is not null, anything we type will deleted and set the v model to become null. we can bypass it by setting the v-model to null after we select the suggestion, so it'll always accept the first character

for example, I use the item-clicked event: ... v-model="person" @item-clicked="updateInvited" ...

on your javascript

updateInvited: function(item) { this.person = null }

I hope it help

sunupf avatar Apr 17 '20 07:04 sunupf