Skip to content

Commit

Permalink
Merge pull request #13 from KazanExpress/dev
Browse files Browse the repository at this point in the history
Dropdown-like style works.
  • Loading branch information
Raiondesu authored Mar 12, 2018
2 parents cf9b231 + 78a9c2d commit 0bf6bd8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 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 @@ -90,7 +90,7 @@
if (!query) return result;
const replace = str => (result = result.replace(str, str.bold()));
const replace = str => (result = result ? result.replace(str, str.bold()) : result);
const texts = query.split(/[\s-_/\\|\.]/gm).filter(t => !!t) || [''];
const procs = [
s => s[0].toUpperCase() + s.substr(1),
Expand Down
10 changes: 7 additions & 3 deletions lib/vue-simple-suggest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default {
return this.slotIsComponent ? '$off' : 'removeEventListener'
},
hoveredIndex () {
return this.suggestions.findIndex(el => this.hovered && (this.hovered[this.valueAttribute] == el[this.valueAttribute]))
return this.suggestions.findIndex(el => this.hovered && (this.valueProperty(this.hovered) == this.valueProperty(el)))
}
},
created() {
Expand Down Expand Up @@ -175,7 +175,7 @@ export default {
},
hideList (ignoreSelection = false) {
if (this.listShown) {
if (this.hovered && this.text && !ignoreSelection) {
if (this.hovered && !ignoreSelection) {
this.select(this.hovered)
}
this.listShown = false
Expand All @@ -188,7 +188,11 @@ export default {
this.$emit('showList')
}
},
onInputClick (event) {
async onInputClick (event) {
if (this.minLength === 0 && !this.text) {
await this.research();
}
if (!this.listShown && this.suggestions.length > 0) {
this.showList()
}
Expand Down

0 comments on commit 0bf6bd8

Please sign in to comment.