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

Add config option for what should happen when enter is pressed #189

Closed
nornes opened this issue Mar 25, 2021 · 2 comments
Closed

Add config option for what should happen when enter is pressed #189

nornes opened this issue Mar 25, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@nornes
Copy link

nornes commented Mar 25, 2021

We are using the autocomplete on a search input which should present the user with options (links) and submit to the search page when enter is pressed. Because of the solution to #104 this doesn't work.

I suggest a config option that lets the developer choose if default form action should run on enter or not. That would (hopefully) make everyone happy :) It could be as simple as a boolean in the config and would help us a lot! Now we have to do manual checks outside the autocomplete which feel hacky.

@nornes nornes added the enhancement New feature or request label Mar 25, 2021
@TarekRaafat
Copy link
Owner

Hello @nornes,

Thanks for sharing your use case.

I've already implemented a solution for your use case and it will be released in the upcoming version.

Cheers, and have a nice day! :)

@TarekRaafat
Copy link
Owner

Using v9.0 you can use the below code snippet to get the results you want to achieve.

trigger: {
  event: ["keydown"],
  condition: (event) => {
    return event.key === "Enter";
  }
}

Here is a live example of this solution as well.

Please try it and let me know how it goes.

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

No branches or pull requests

2 participants