Skip to content

Commit

Permalink
fix(CommandPalette): activate next option on mounted
Browse files Browse the repository at this point in the history
  • Loading branch information
flozdra committed Nov 16, 2023
1 parent a989dab commit 0837039
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/runtime/components/navigation/CommandPalette.vue
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export default defineComponent({
onMounted(() => {
if (props.autoselect) {
activateFirstOption()
activateNextOption()
}
})
Expand Down Expand Up @@ -319,6 +319,13 @@ export default defineComponent({
}, 0)
}
function activateNextOption () {
setTimeout(() => {
// https://github.com/tailwindlabs/headlessui/blob/6fa6074cd5d3a96f78a2d965392aa44101f5eede/packages/%40headlessui-vue/src/components/combobox/combobox.ts#L769
comboboxInput.value?.$el.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown' }))
}, 0)
}
function onSelect (option: Command | Command[]) {
emit('update:modelValue', option, { query: query.value })
Expand Down

0 comments on commit 0837039

Please sign in to comment.