Vue-select: pressing Enter key submits the form

Created on 2 Aug 2016  路  20Comments  路  Source: sagalbot/vue-select

When using up/down keys and then enter key to select it submits the form.. how do i stop it propagating the event?

bug

Most helpful comment

Add @keydown.enter.prevent.self to form tag or parent of where event fires.

All 20 comments

In your form element add @submit.prevent=""

i'm using vue-formular ... if you know sth better for handling validation easy.. i'm new to Vue and open to suggestions but i don't think @submit.prevent="" will work with vf-form

my bad did not realize you were using vue-formular

Hi @purepear thanks for bringing this up. I had @keyup.enter.prevent="typeAheadSelect", but what I really need is @keyup.enter.stop="typeAheadSelect" to stop the enter key event from bubbling up. Will fix and release today.

Hi @sagalbot, @nacr-dev i did some testing and i fixed it by adding <vue-select @keydown.enter.prevent="" ...> component itself

please more descript about problam ...
i hav somting problam
i have a form and use v-select ajax and when select in list by enter my form submiting but i whant submit when click btn submit form

this hasn't been fixed yet? :(

@ReneMoraales
hi don't remember i change my plugin vue-multiselect

Having this issue as well.

Same Here. Having this issue as well.

I added @keydown.enter.prevent="" in the form tag which wraps the component that will have the v-select inside.

I had to add it to the parent component, not to the form itself, as v-select in my case is not a direct child of the <form> element.

<form>
  <component> <!-- Added @keydown.enter.prevent on the root element of this component -->
    <v-select>

I dont understand why this is closed. This is still an issue. Why would pressing enter in the search field of the v-select cause the form to submit? Seems like very unexpected behaviour.

Add @keydown.enter.prevent.self to form tag or parent of where event fires.

Hi @gdev219 , thank you, works perfectly!

Add @keydown.enter.prevent.self to form tag or parent of where event fires.

Just to clarify, it turns out that it's enough to put "@keydown.enter.prevent.self" with no value to any DOM element which is a child of the form and a parent of the vue-select.

<div @keydown.enter.prevent.self>
<v-select ... />
</div>

Add @keypress.enter.native.prevent="" to the v-select element.

So enter to submit form still work in native form element (outside v-select element)

Adding @keypress.enter.native.prevent="" isn't a good solution for me. The @keypress.enter.native.prevent="" prevent the enter key in the multiselect so the user can't chose an option with press enter.

Hello

I got an answer here please take a look

Vue prevent form submit on enter

thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rudykaze picture rudykaze  路  3Comments

pud1m picture pud1m  路  3Comments

davidalvarezr picture davidalvarezr  路  3Comments

fabianmieller picture fabianmieller  路  3Comments

theseawolves picture theseawolves  路  4Comments