Open bogdan-dubyk opened 4 years ago
Okay, I probably found what causes the issue but not sure how to solve it...
The issue is because the inner input has @focusout="cityError"
, and looks like when I select a value it's triggering focusout
instead of select
event, but in such a case why it's working when I select a value for a second time
Small code snippet
<vue-simple-suggest
v-model="city.searchInput"
:debounce="300"
min-length="2"
display-attribute="name"
value-attribute="id"
:list="getCity"
:filter-by-query="true"
@select="citySelect"
>
<input
type="search"
class="form-control"
placeholder="Place of birth"
@focusout="cityError"
>
</vue-simple-suggest>
....
methods: {
cityError() {
console.log('cityError'); ,<== when I select some item from suggestions list by the first time this event triggered
},
citySelect() {
console.log('citySelect'); <===== when I'm clicking by input second time (the suggestions list already loaded) and select some (or same) value from suggestions list this event triggered
},
getCity() {
// here should be ajax call, but for now just dummy data
return [
{"id": "691b237b0322f28988f3ce03e321ff72a12167fd", "name": "Paris", "lat": -33.8599358, "lng": 151.2090295},
{"id": "691b237b0322f28988f3ce03e321ff72a12167fs", "name": "New York", "lat": -33.8599358, "lng": 151.2090295},
]
}
}
when I remove @focusout="cityError"
, @select
triggering in the first select as it should, but I can't handle required validation in fly when the user does not choose any value at all
FYI: when I'm trying to select an item from the suggestions list for the third time, fourth time and so, all the time it triggering focusout
I'm submitting a ...
What is the current behavior?
select
/suggestion-click
not firing on the first click on list element, only after selecting the element second timeIf the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
here is the element template:
Here is the actual js:
What is the expected behavior?
It should trigger
getCity
method after I select some element from the listHow 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>
)Please tell us about your environment:
Here is the small video I recorded to show the issue https://drive.google.com/file/d/1z6WtRK8-BMxe2GyLphD-u7Zf8fUolQlg/view?usp=sharing