-
Notifications
You must be signed in to change notification settings - Fork 74
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
Clearing the input when an item has been selected #99
Comments
The way I solved this is a bit of hack but seems to work. First I set the model binding of the input to the same variable that is bound to the suggest component (v-model="chosen"):
Then on the select event after nextTick I set the model variable to empty:
|
Thanks that works! Although it is a horrible hack, hopefully this gets resolved in a future release. For anyone (like me) that finds this and doesn't know what $nextTick is:
|
Hello, @robjbrain. This will indeed be resolved in a future 1.9.0 release! Thank you for using our little component! As for the issue, I'll keep it open for task-management purposes. P.S. @RMFogarty, great workaround btw! |
As far as I can tell the "fix" introduced in commit b159ce6 doesn't help and worse it breaks the work-around @RMFogarty suggested. Now after the 'select' event is run it waits for nextTick via setText and THEN overwrites my changes to the text. Maybe a better solution would be to unwind the 'setText/nextTick' change and instead use one of the following:
P.S. I like the control, it's very flexible. thanks! |
I'm submitting a ...
What is the current behavior?
When an item is selected the old input stays there.
What is the expected behavior?
There should be a simple way to clear the old input after an item has been selected
How are you importing Vue-simple-suggest?
import VueSimpleSuggest from 'vue-simple-suggest/lib'
)import VueSimpleSuggest from 'vue-simple-suggest'
)import VueSimpleSuggest from 'vue-simple-suggest/dist/es7'
)import VueSimpleSuggest from 'vue-simple-suggest'
)const VueSimpleSuggest = require('vue-simple-suggest')
)<script type="text/javascript" src="https://unpkg.com/vue-simple-suggest"></script>
)What is the motivation / use case for changing the behavior?
I'm not sure if this is a support request or a feature request, it depends on whether or not it's actually possible. It seems like a simple enough request, but a little dive into the code suggests it might not be possible.
When an item is selected i'd like to clear the text from the input field.
The following doesn't work:
From what I can tell it's literally impossible because of this little snippet of code:
Since my
onSelect
method will always be called whenthis.$emit('select', item)
happens anything I do will always be overwritten by the next line where it auto completesthis.autocompleteText(this.displayProperty(item))
One thing I have considered is clearing on focus and blurring after selection but
this.$refs.input.blur()
throws an error andthis.$refs.input.$el.blur()
doesn't seem to actually blur.The text was updated successfully, but these errors were encountered: