Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont submit form when pressing Enter #146

Open
brentgreeff opened this issue Jan 29, 2024 · 0 comments
Open

Dont submit form when pressing Enter #146

brentgreeff opened this issue Jan 29, 2024 · 0 comments

Comments

@brentgreeff
Copy link

When the input used for searching is part of a form with other fields,
its very easy to use the Enter to select an option, but then also to press Enter and submit the whole form,
which I did accidentally many times.

data-autocomplete-submit-on-enter-value="false" - does not do what I would expect.

input[type="text" data-autocomplete-target="input" data-action="keydown.enter->autocomplete#bad"]
class CustomAutocomplete extends Autocomplete {

  bad(e) {
    e.preventDefault()
  }
}
application.register('autocomplete', CustomAutocomplete)

This worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant