Skip to content

Commit

Permalink
fix: keyboard nav on group select fix #354
Browse files Browse the repository at this point in the history
  • Loading branch information
adamberecz committed Oct 7, 2023
1 parent bb6d6b7 commit 6d84dea
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/composables/useOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default function useOptions (props, context, dep)
const clearSearch = dep.clearSearch
const update = dep.update
const pointer = dep.pointer
const setPointer = dep.setPointer
const clearPointer = dep.clearPointer
const focus = dep.focus
const deactivate = dep.deactivate
Expand Down Expand Up @@ -496,6 +497,11 @@ export default function useOptions (props, context, dep)
.filter((o, k) => iv.value.length + 1 + k <= max.value || max.value === -1)
)
}

if (hideSelected.value && pointer.value) {
// Refresh pointer because pointer.__VISIBLE__ are not reactive #354
setPointer(fg.value.filter(g => !g[disabledProp.value])[pointer.value.index])
}
break
}

Expand Down
29 changes: 29 additions & 0 deletions tests/unit/composables/usePointerAction.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,35 @@ describe('usePointer Action', () => {

expect(select.vm.pointer.label).toBe('11')
})

it('should point at next group after full group is selected when hideSelected=true', async () => {
let select = createSelect({
mode: 'multiple',
value: [],
hideSelected: true,
closeOnSelect: false,
options: [
{
label: 'First',
options: [1,2,3],
},
{
label: 'Second',
options: [4,5,6],
},
],
groups: true
})

select.vm.pointer = select.vm.fg[0]
select.vm.selectPointer()

await nextTick()

select.vm.forwardPointer()

expect(select.vm.pointer.label).toBe('Second')
})
})

describe('backwardPointer', () => {
Expand Down

0 comments on commit 6d84dea

Please sign in to comment.