Autocomplete: Don't prevent form submit

pull/6571/head
leezng 2017-08-15 13:30:12 +08:00 committed by 杨奕
parent 7753bd8931
commit 5268a8f8c1
1 changed files with 3 additions and 2 deletions

View File

@ -10,7 +10,7 @@
@focus="handleFocus" @focus="handleFocus"
@keydown.up.native.prevent="highlight(highlightedIndex - 1)" @keydown.up.native.prevent="highlight(highlightedIndex - 1)"
@keydown.down.native.prevent="highlight(highlightedIndex + 1)" @keydown.down.native.prevent="highlight(highlightedIndex + 1)"
@keydown.enter.native.prevent="handleKeyEnter" @keydown.enter.native="handleKeyEnter"
@keydown.native.tab="close" @keydown.native.tab="close"
> >
<template slot="prepend" v-if="$slots.prepend"> <template slot="prepend" v-if="$slots.prepend">
@ -133,8 +133,9 @@
close(e) { close(e) {
this.activated = false; this.activated = false;
}, },
handleKeyEnter() { handleKeyEnter(e) {
if (this.suggestionVisible && this.highlightedIndex >= 0 && this.highlightedIndex < this.suggestions.length) { if (this.suggestionVisible && this.highlightedIndex >= 0 && this.highlightedIndex < this.suggestions.length) {
e.preventDefault()
this.select(this.suggestions[this.highlightedIndex]); this.select(this.suggestions[this.highlightedIndex]);
} }
}, },