Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(VSelect): emit selected listIndex event #7828

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
d5e9aeb
docs(component): menuListIndex event added to docs
mateuszgachowski Jul 15, 2019
a32ca0b
feat(VSelect): add update:listIndex event to VSelect
mateuszgachowski Jul 15, 2019
c21ddbe
chore(deps): bump lodash.template from 4.4.0 to 4.5.0 (#7808)
dependabot[bot] Jul 16, 2019
52da037
chore(release): publish v2.0.0-beta.8
johnleider Jul 16, 2019
670d134
docs(vue-analytics): revert autoTracking parameter
johnleider Jul 16, 2019
ee9e374
feat(VSelect): code review updates, name unification
mateuszgachowski Jul 17, 2019
bfadbf7
feat(VSelect): event name update:listIndex -> update:list-index
mateuszgachowski Jul 18, 2019
785315d
Merge branch 'next' into feat/v-autocomplete-selection
mateuszgachowski Jul 20, 2019
17e0889
Merge branch 'next' into feat/v-autocomplete-selection
mateuszgachowski Jul 20, 2019
fa9e020
Merge branch 'next' into feat/v-autocomplete-selection
mateuszgachowski Jul 20, 2019
39ee1a9
Merge branch 'next' into feat/v-autocomplete-selection
mateuszgachowski Jul 22, 2019
dd71e74
Merge branch 'next' into feat/v-autocomplete-selection
mateuszgachowski Jul 22, 2019
a94906d
Merge branch 'next' into feat/v-autocomplete-selection
mateuszgachowski Jul 22, 2019
76cb80b
Merge branch 'dev' into feat/v-autocomplete-selection
MajesticPotatoe Jul 24, 2019
e79211d
Merge branch 'dev' into feat/v-autocomplete-selection
mateuszgachowski Jul 29, 2019
59960cf
Merge branch 'dev' into feat/v-autocomplete-selection
mateuszgachowski Aug 3, 2019
88f1013
Merge branch 'next' into feat/v-autocomplete-selection
mateuszgachowski Sep 10, 2019
3c91cea
Merge branch 'feat/v-autocomplete-selection'
mateuszgachowski Sep 10, 2019
dc33758
Merge remote-tracking branch 'upstream/dev'
mateuszgachowski Sep 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/api-generator/src/helpers/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ const VSelect = {
name: 'update:search-input',
value: 'string',
},
{
name: 'update:list-index',
value: 'number',
},
...inputEvents,
...textEvents,
].concat(validatableEvents),
Expand Down
1 change: 1 addition & 0 deletions packages/docs/src/lang/en/components/Autocompletes.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"click:prepend": "Components.Inputs.events['click:prepend']",
"click:prepend-inner": "Components.TextFields.events['click:prepend-inner']",
"update:error": "Mixins.Validatable.events['update:error']",
"update:list-index": "Components.Selects.events['update:list-index']",
"update:search-input": "The `search-input.sync` event"
}
}
1 change: 1 addition & 0 deletions packages/docs/src/lang/en/components/Combobox.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"click:prepend": "Components.Inputs.events['click:prepend']",
"click:prepend-inner": "Components.TextFields.events['click:prepend-inner']",
"update:error": "Mixins.Validatable.events['update:error']",
"update:list-index": "Components.Selects.events['update:list-index']",
"update:search-input": "The `search-input.sync` event"
}
}
1 change: 1 addition & 0 deletions packages/docs/src/lang/en/components/Selects.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"click:prepend-inner": "Components.TextFields.events['click:prepend-inner']",
"focus": "Emitted when component is focused",
"update:error": "Mixins.Validatable.events['update:error']",
"update:list-index": "Emitted when menu item is selected using keyboard arrows",
"update:search-input": "The `search-input.sync` event"
}
}
1 change: 1 addition & 0 deletions packages/vuetify/src/components/VSelect/VSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ export default baseMixins.extend<options>().extend({
// listIndex change from menu
if (this.isMenuActive && keyCode !== keyCodes.tab) {
menu.changeListIndex(e)
this.$emit('update:list-index', menu.listIndex)
}

// If menu is not active, up and down can do
Expand Down
20 changes: 20 additions & 0 deletions packages/vuetify/src/components/VSelect/__tests__/VSelect4.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,26 @@ describe('VSelect.ts', () => {
expect(wrapper.vm.$refs.menu.listIndex).toBe(-1)
})

it('should emit listIndex event when navigated by keyboard', () => {
const wrapper = mountFunction({
propsData: {
items: ['foo', 'bar'],
},
})

const listIndexUpdate = jest.fn()
wrapper.vm.$on('update:list-index', listIndexUpdate)

const input = wrapper.find('input')
const slot = wrapper.find('.v-input__slot')
slot.trigger('click')

input.trigger('keydown.down')
expect(listIndexUpdate).toHaveBeenCalledWith(0)
input.trigger('keydown.down')
expect(listIndexUpdate).toHaveBeenCalledWith(1)
})

it('should not change value when typing on readonly field', async () => {
const wrapper = mountFunction({
propsData: {
Expand Down