Skip to content

Commit bf59aa4

Browse files
wilcorrearstoenescu
authored andcommitted
feat: "selected" event for Autocomplete component
1 parent 914559b commit bf59aa4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/vue-components/autocomplete/Autocomplete.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
:item="result"
1717
link
1818
:active="selectedIndex === index"
19-
@click.native="setValue(result.value)"
19+
@click.native="setValue(result)"
2020
></q-list-item>
2121
</div>
2222
</q-popover>
@@ -135,16 +135,17 @@ export default {
135135
this.results = []
136136
this.selectedIndex = -1
137137
},
138-
setValue (val) {
139-
this.model = val
138+
setValue (result) {
139+
this.model = result.value
140+
this.$emit('selected', result)
140141
this.close()
141142
},
142143
move (offset) {
143144
this.selectedIndex = Utils.format.between(this.selectedIndex + offset, -1, this.computedResults.length - 1)
144145
},
145146
setCurrentSelection () {
146147
if (this.selectedIndex >= 0) {
147-
this.setValue(this.results[this.selectedIndex].value)
148+
this.setValue(this.results[this.selectedIndex])
148149
}
149150
},
150151
__updateDelay () {

0 commit comments

Comments
 (0)