-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Feature (Typeahead): Keydown.Enter without focused item to trigger selectItem event #877
Comments
@kjartanvalur I'm sorry but I don't think I understand the use-case. Could you elaborate? More specifically this part is not clear at all:
Sorry for being pain in a neck but I want to make sure that I understand the use-case before we change the API. |
@pkozlowski-opensource, sure I understand. What I´m trying to do is a autosuggest search input on remote datasource (>100k items) and I also configure selectFirst=false. So when a user types in a search query and does not select from the auto suggest results and hits the Enter key, then I redirect to a search page with that search text he has entered. This is somewhat a standard behaviour in all search inputs, like e.g. amazon, imdb etc. The problem is that if i configure (keyup.enter)="navigateToSearch(searchText)" then it conflicts with the enter event in the typeahead control that triggers onSelectedItem. |
This sounds like a reasonable request - this would be an easy thing to create a PR, maybe with input |
@wesleycho |
I am running into the same use case, and can put out a PR to fix this. I just want to make sure we are all on the same page with the resolution before doing so. As far as I can tell there are a few solutions:
@wesleycho, the third option there is I believe what you were trying to say, but I'm not sure that would work as well. It would require the user to then handle the selection event themselves. |
If it helps anyone out, as a temporary work around, you can bind to the keyup event of the input instead of keydown or keypress |
@deeg Hi. It would be awesome if you could put out a PR 👍 |
I started going down the path of the first solution and realized there are some issues with it:
I'm going to wait what people think about the above, and think on a good solution and wrap up the PR. For now I'm finding using the keyup event works very well for me right now. |
@deeg so I'm reviewing typeahead related issues and after re-reading #980 I'm not sure anymore if firing How about we do the following:
This way we could keep I'm still not sure if the above proposal covers all use-cases described here and in #980 so another pair of eyes would help clarify things. cc @stevewarsa |
@pkozlowski-opensource |
Not sure what you mean by "deselecting an item"... |
@pkozlowski-opensource, I'm not sure of the difference between this ticket and #980. I feel like both solutions will work for both tickets, and I'm fine with going the route you just proposed above.
I can change the PR I have open later tonight or tomorrow. |
I mean when a user already selected an item and he wants to clear selected item (e.g. reset form). I was just wondering what would be the preferred way and maybe it would conflict with this resolution. |
Closes ng-bootstrap#958 Closes ng-bootstrap#877 Closes ng-bootstrap#980 Closes ng-bootstrap#1032
Use case:
Specially when the new config focusFirst is set to false then users will sometimes just want to press enter although no item is selected/focused. Then most of the time the behaviour is to redirect to search result page.
Solution:
SelectItem event can be triggered with value.item = null when enter key is pressed and no item is selected/focused.
The text was updated successfully, but these errors were encountered: