Skip to content

Commit

Permalink
Merge pull request #22 from KazanExpress/dev
Browse files Browse the repository at this point in the history
1.3.0
  • Loading branch information
Raiondesu authored Mar 31, 2018
2 parents be49d92 + 312259b commit c657686
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@hover="onSuggestHover"
@focus="onFocus"
@blur="onBlur"
@requests-tart="onRequestStart"
@request-start="onRequestStart"
@request-done="onRequestDone"
@request-failed="onRequestFailed"
@show-list="onShowList"
Expand Down
23 changes: 11 additions & 12 deletions lib/vue-simple-suggest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
:query="text"
></slot>

<div class="suggest-item" v-for="suggestion in suggestions"
<div class="suggest-item" v-for="(suggestion, index) in suggestions"
@mouseenter="hover(suggestion, $event.target)"
@mouseleave="hover(null, $event.target)"
:key="valueProperty(suggestion)"
:key="isPlainSuggestion ? 'suggestion-' + index : valueProperty(suggestion)"
:class="{
selected: selected && (valueProperty(suggestion) == valueProperty(selected)),
hover: hovered && (valueProperty(hovered) == valueProperty(suggestion))
Expand Down Expand Up @@ -118,15 +118,15 @@ export default {
canSend: true,
timeoutInstance: null,
text: this.value,
isSuggestionConverted: false,
isPlainSuggestion: false,
controlScheme: {}
}
},
computed: {
slotIsComponent () {
return (this.$slots.default && this.$slots.default.length > 0) && !!this.$slots.default[0].componentInstance
},
listIsRequest() {
listIsRequest () {
return typeof this.list === 'function';
},
input () {
Expand Down Expand Up @@ -156,13 +156,15 @@ export default {
},
methods: {
displayProperty (obj) {
return fromPath(obj, this.displayAttribute);
return this.isPlainSuggestion ? obj : fromPath(obj, this.displayAttribute);
},
valueProperty (obj) {
return fromPath(obj, this.valueAttribute);
return this.isPlainSuggestion ? obj : fromPath(obj, this.valueAttribute);
},
select (item) {
this.selected = item
// Get current item regardless of internal structure
this.$emit('select', item)
// Ya know, input stuff
Expand All @@ -178,6 +180,7 @@ export default {
hover (item, elem) {
this.hovered = item
if (this.hovered != null) {
// Send current item regardless of internal structure
this.$emit('hover', item, elem)
}
},
Expand Down Expand Up @@ -333,13 +336,9 @@ export default {
if (!Array.isArray(result)) { result = [result] }
if (typeof result[0] === 'object' && !Array.isArray(result[0])) {
this.isSuggestionConverted = false;
this.isPlainSuggestion = false;
} else {
result = result.map((el, i) => ({
[this.valueAttribute]: i,
[this.displayAttribute]: el
}));
this.isSuggestionConverted = true;
this.isPlainSuggestion = true;
}
if (this.filterByQuery) {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-simple-suggest",
"description": "Feature-rich autocomplete component for Vue.js",
"version": "1.2.6",
"version": "1.3.0",
"author": "KazanExpress",
"license": "MIT",
"repository": "KazanExpress/vue-simple-suggest",
Expand Down

0 comments on commit c657686

Please sign in to comment.