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

Suggestion: Emit event on show/hide suggestions #178

Closed
BerniML opened this issue Mar 13, 2020 · 1 comment
Closed

Suggestion: Emit event on show/hide suggestions #178

BerniML opened this issue Mar 13, 2020 · 1 comment

Comments

@BerniML
Copy link
Contributor

BerniML commented Mar 13, 2020

I'm trying to detect when the suggestions are rendered, and I think an event emit could be added when the component renders the suggestion and hides it.

The problematic scenario is:

I need to allow the browser autofill as long as the autosuggest is not rendering any suggestion.
When the suggestion is rendered, I need to detect it, and change the autocomplete property in the input-props property to disable the browser autofill.

The case scenario would be the following:

Give a default value to autocomplete attribute in input-props.
This value enables browser autofill.
User ignores browser autofill and starts typing in the vue-autosuggest input, which renders some suggestions.
Detect through the an emitted event such as renderedSuggestion that the suggestion is being shown
Change the value of the autocomplete property to hide the browser autofill.
I would also need to detect when the suggestions are hidden, to restore the property to it's default value.

Suggested solution:

Add new event to be triggered when the suggestion is shown and hidden.

If you agree on the solution, I'll try to get some time to do a Pull request.
Also, if you can think about a better name for the emitted event, please do tell.

Thanks!

@darrenjennings
Copy link
Owner

Yea sounds like a good enhancement since @ events are more the vue way. The component already has a way of handling open/close events with should-render-suggestions. You can perform side effects inside this function based on what you determine.

https://github.com/darrenjennings/vue-autosuggest#shouldRenderSuggestions

BerniML added a commit to BerniML/vue-autosuggest that referenced this issue Mar 29, 2020
New showRenderedSuggestions and hideRenderedSuggestions events to facilitate event handling when
suggestions appear and disappear

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

No branches or pull requests

2 participants