Skip to content
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

Input deleted after having one item selected #67

Open
kno opened this issue Jul 14, 2018 · 6 comments
Open

Input deleted after having one item selected #67

kno opened this issue Jul 14, 2018 · 6 comments

Comments

@kno
Copy link

kno commented Jul 14, 2018

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.

@krugerdavid
Copy link

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

@Garima
Copy link

Garima commented Aug 7, 2018

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

@paliari Please help

@RomkaLTU
Copy link

Set item: null, not false or {}

@dstrohschein
Copy link

dstrohschein commented Feb 19, 2020

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
     }
  }

@andhikayuana
Copy link

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

@sunupf
Copy link

sunupf commented Apr 17, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants