Skip to content

Commit

Permalink
Focus on selectedItemByArrows
Browse files Browse the repository at this point in the history
Add itemsLimit prop
Fix lint error "You should not mix 'v-for' with 'v-if'"
  • Loading branch information
mariosh346 committed Mar 5, 2019
1 parent 2496190 commit 7f30c6e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/component.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@
'IZ-select__item': true,
'IZ-select__item--selected': isItemSelected(item)
}"
tabindex="-1"
@click="onClickSelectItem(item)"
:ref="'items'"
>
<slot
:item="item"
Expand Down Expand Up @@ -148,8 +150,7 @@ export default {
focused: false,
selectedItem: null,
selectedItemByArrows: null,
// TODO create a prop
itemsLimit: 20,
// used only in the "search" computed (setter + getter)
searchData: ''
}),
computed,
Expand Down
3 changes: 3 additions & 0 deletions src/eventsListeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export default {
this.fireSelectEvent(this.selectedItem)
}

let selectedElement = this.$refs.items[this.arrowsIndex]
if (selectedElement) selectedElement.focus()

e.preventDefault()
},
onEnter () {
Expand Down
5 changes: 5 additions & 0 deletions src/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ export default {
required: true,
note: 'array of suggestions (data fetched from backend, etc)'
},
itemsLimit: {
type: Number,
default: 20,
note: 'property in item for text'
},
itemText: {
type: String,
default: null, // 'text',
Expand Down

0 comments on commit 7f30c6e

Please sign in to comment.