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

How to trigger @submit from external button #109

Open
maximelebreton opened this issue Sep 17, 2020 · 3 comments
Open

How to trigger @submit from external button #109

maximelebreton opened this issue Sep 17, 2020 · 3 comments
Labels
question Further information is requested

Comments

@maximelebreton
Copy link

maximelebreton commented Sep 17, 2020

Hello @trevoreyre, and thanks for your plugin!

I'm using autocomplete-vue and want to add a "Search" <button>, like on the google page, to trigger the keyboard selected result (or the first if no one is selected):

but I can't find a way to trigger the @submit event from a button!

Precision: the behaviour of this codepen is not what i'm looking for: https://codepen.io/trevoreyre/pen/RwwNKLK?editors=1111

Thanks for your help!

@trevoreyre
Copy link
Owner

I'm not sure what the difference is between the CodePen example you linked and the Google search behavior. Can you explain a little more?

@trevoreyre trevoreyre added the question Further information is requested label Sep 17, 2020
@maximelebreton
Copy link
Author

maximelebreton commented Sep 17, 2020

Yes of course!

Here is a GIF to illustrate the difference:
autocomplete

Actual behaviour:
On the CodePen example:

  • ✔️First case: Click on the third result takes the result as input and triggers the autocomplete's @submit function (expected behaviour)
  • Second case: Select the third result with keyboard and click on the Search button only triggers the handleFormSubmit function, and has no effect on the autocomplete (unexpected behaviour)

Desired behaviour:

  • First case: nothing to change!
  • Second case: When I press the Search button, I want to trigger the autocomplete @submit function (not the form submit).
    (if no result is selected with keyboard, it takes the first result by default)

I hope to be clearer :)

Thanks!

@maximelebreton
Copy link
Author

Hello @trevoreyre, are my explanations clearer?

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

No branches or pull requests

2 participants