Skip to content

Commit

Permalink
fix(VCombobox): re-compute menu items before setting index (#13825)
Browse files Browse the repository at this point in the history
fixes #12567
  • Loading branch information
KaelWD committed Jun 28, 2021
1 parent 235bf94 commit 8c0e2bc
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions packages/vuetify/src/components/VSelect/VSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -658,12 +658,6 @@ export default baseMixins.extend<options>().extend({
const keyCode = e.keyCode
const menu = this.$refs.menu

// If enter, space, open menu
if ([
keyCodes.enter,
keyCodes.space,
].includes(keyCode)) this.activateMenu()

this.$emit('keydown', e)

if (!menu) return
Expand All @@ -677,6 +671,12 @@ export default baseMixins.extend<options>().extend({
})
}

// If enter, space, open menu
if ([
keyCodes.enter,
keyCodes.space,
].includes(keyCode)) this.activateMenu()

// If menu is not active, up/down/home/end can do
// one of 2 things. If multiple, opens the
// menu, if not, will cycle through all
Expand Down Expand Up @@ -709,6 +709,7 @@ export default baseMixins.extend<options>().extend({
if (!menu || !this.isDirty) return

// When menu opens, set index of first active item
this.$refs.menu.getTiles()
for (let i = 0; i < menu.tiles.length; i++) {
if (menu.tiles[i].getAttribute('aria-selected') === 'true') {
this.setMenuIndex(i)
Expand Down Expand Up @@ -839,11 +840,6 @@ export default baseMixins.extend<options>().extend({
(this.$refs.menu as { [key: string]: any }).updateDimensions()
})

// We only need to reset list index for multiple
// to keep highlight when an item is toggled
// on and off
if (!this.multiple) return

const listIndex = this.getMenuIndex()

this.setMenuIndex(-1)
Expand Down

0 comments on commit 8c0e2bc

Please sign in to comment.