Skip to content

Custom event when enter is pressed without a selection #108

@antoinematyja

Description

@antoinematyja

I'm submitting a ...

  • bug report
  • feature request
  • support request

What is the current behavior?

The control select (binded to Enter by default) allows this behaviour:

If the list is shown - chooses the highlighted element, if the list is hidden - refills the suggestions based on current input text. Defined by select property.

What is the expected behavior?

It would be nice to have a behaviour :

  • if the list is shown, choose the highlighted element
  • otherwise trigger an event "it was submitted without a suggestion selected"

What is the motivation / use case for changing the behavior?

I have a geolocation input working pretty much like the one on Google Maps.

When the user types a city, it provides suggestions from a third-party API. The user can select a suggestion, or just hit enter to perform a text search.

This component is perfect to display suggestions/select a suggestion, however if the user hits enter without selecting a suggestion, it will just hide the suggestions with no possibility to catch the event. If the user hits enter again, it will show again the list and refill it.

From what I saw, it happens here:
https://github.com/KazanExpress/vue-simple-suggest/blob/master/lib/vue-simple-suggest.vue#L339

If the user hasn't selected a suggestion, this.hovered has no value so it won't trigger the select event.

Since the user doesn't really select a suggestion, maybe this should trigger another event name. Not sure what the best solution is. Maybe it should be a different control ?

Otherwise this component is awesome, many thanks ! 😃

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestminorThis is a thing to include in the next minor releaseresolvedThis issue is resolved in the latest version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions