Skip to content
Closed
Changes from all commits
Commits
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
21 changes: 13 additions & 8 deletions src/composables/useKeyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function useKeyboard (props, context, dep)
const preparePointer = () => {
// When options are hidden and creating tags is allowed
// no pointer will be set (because options are hidden).
// In such case we need to set the pointer manually to the
// In such case we need to set the pointer manually to the
// first option, which equals to the option created from
// the search value.
if (mode.value === 'tags' && !showOptions.value && createOption.value && searchable.value && !groupped.value) {
Expand All @@ -67,44 +67,49 @@ export default function useKeyboard (props, context, dep)
if (iv.value.length === 0) {
return
}

update([...iv.value].slice(0,-1))
break

case 'Enter':
e.preventDefault()

if (e.keyCode === 229) {
// ignore IME confirmation
return
}

if (addOptionOn.value.indexOf('enter') === -1 && createOption.value) {
return
}

preparePointer()
selectPointer()
break

case ' ':
if (!createOption.value && !searchable.value) {
e.preventDefault()

preparePointer()
selectPointer()
return
}

if (!createOption.value) {
return false
}
}

if (addOptionOn.value.indexOf('space') === -1 && createOption.value) {
return
}

e.preventDefault()

preparePointer()
selectPointer()
break

case 'Tab':
case ';':
case ',':
Expand Down Expand Up @@ -147,4 +152,4 @@ export default function useKeyboard (props, context, dep)
handleKeydown,
preparePointer,
}
}
}