Skip to content

Commit c657686

Browse files
authored
Merge pull request #22 from KazanExpress/dev
1.3.0
2 parents be49d92 + 312259b commit c657686

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

docs/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
@hover="onSuggestHover"
2424
@focus="onFocus"
2525
@blur="onBlur"
26-
@requests-tart="onRequestStart"
26+
@request-start="onRequestStart"
2727
@request-done="onRequestDone"
2828
@request-failed="onRequestFailed"
2929
@show-list="onShowList"

lib/vue-simple-suggest.vue

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
:query="text"
1717
></slot>
1818

19-
<div class="suggest-item" v-for="suggestion in suggestions"
19+
<div class="suggest-item" v-for="(suggestion, index) in suggestions"
2020
@mouseenter="hover(suggestion, $event.target)"
2121
@mouseleave="hover(null, $event.target)"
22-
:key="valueProperty(suggestion)"
22+
:key="isPlainSuggestion ? 'suggestion-' + index : valueProperty(suggestion)"
2323
:class="{
2424
selected: selected && (valueProperty(suggestion) == valueProperty(selected)),
2525
hover: hovered && (valueProperty(hovered) == valueProperty(suggestion))
@@ -118,15 +118,15 @@ export default {
118118
canSend: true,
119119
timeoutInstance: null,
120120
text: this.value,
121-
isSuggestionConverted: false,
121+
isPlainSuggestion: false,
122122
controlScheme: {}
123123
}
124124
},
125125
computed: {
126126
slotIsComponent () {
127127
return (this.$slots.default && this.$slots.default.length > 0) && !!this.$slots.default[0].componentInstance
128128
},
129-
listIsRequest() {
129+
listIsRequest () {
130130
return typeof this.list === 'function';
131131
},
132132
input () {
@@ -156,13 +156,15 @@ export default {
156156
},
157157
methods: {
158158
displayProperty (obj) {
159-
return fromPath(obj, this.displayAttribute);
159+
return this.isPlainSuggestion ? obj : fromPath(obj, this.displayAttribute);
160160
},
161161
valueProperty (obj) {
162-
return fromPath(obj, this.valueAttribute);
162+
return this.isPlainSuggestion ? obj : fromPath(obj, this.valueAttribute);
163163
},
164164
select (item) {
165165
this.selected = item
166+
167+
// Get current item regardless of internal structure
166168
this.$emit('select', item)
167169
168170
// Ya know, input stuff
@@ -178,6 +180,7 @@ export default {
178180
hover (item, elem) {
179181
this.hovered = item
180182
if (this.hovered != null) {
183+
// Send current item regardless of internal structure
181184
this.$emit('hover', item, elem)
182185
}
183186
},
@@ -333,13 +336,9 @@ export default {
333336
if (!Array.isArray(result)) { result = [result] }
334337
335338
if (typeof result[0] === 'object' && !Array.isArray(result[0])) {
336-
this.isSuggestionConverted = false;
339+
this.isPlainSuggestion = false;
337340
} else {
338-
result = result.map((el, i) => ({
339-
[this.valueAttribute]: i,
340-
[this.displayAttribute]: el
341-
}));
342-
this.isSuggestionConverted = true;
341+
this.isPlainSuggestion = true;
343342
}
344343
345344
if (this.filterByQuery) {

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-simple-suggest",
33
"description": "Feature-rich autocomplete component for Vue.js",
4-
"version": "1.2.6",
4+
"version": "1.3.0",
55
"author": "KazanExpress",
66
"license": "MIT",
77
"repository": "KazanExpress/vue-simple-suggest",

0 commit comments

Comments
 (0)