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

Typeahead: allow selection veto #699

Closed
pkozlowski-opensource opened this issue Sep 7, 2016 · 2 comments
Closed

Typeahead: allow selection veto #699

pkozlowski-opensource opened this issue Sep 7, 2016 · 2 comments

Comments

@pkozlowski-opensource
Copy link
Member

In some more advanced use-cases a typeahead might display more options than are supposed to be selected by a user. An example of this can be seen on https://www.kayak.com/flights where in addition to flight proposal there is the "Sign up to access recent searches anywhere". It looks like a "normal" option (is displayed in a dropdown, can be iterated over with keyboard etc.) except that it can't be selected and shouldn't result in model binding.

We could easily cover this use-case by giving people ability to veto selection in the selectItem callback (ex. by interpreting false as a return value or changing event we pass to the selectItem function).

@pkozlowski-opensource
Copy link
Member Author

This is similar to typeahead-should-select from http://angular-ui.github.io/bootstrap/#/typeahead. At the same time I don't see why we should be separating typeahead-on-select and typeahead-should-select as we can combine them into one.

My proposal: check the return value from the selectItem callback (if one was defined). If the return value is equal to false then don't write back to the model value.

@pkozlowski-opensource
Copy link
Member Author

Bah, we can't do this... I'm not thinking straight - we are just emitting through EventEmitter so I don't think we can expect a return value. What we would have to do is to provide an event object and have a preventDefault() method on this event object.

@pkozlowski-opensource pkozlowski-opensource modified the milestone: beta.0 (Feature-complete) Sep 14, 2016
@pkozlowski-opensource pkozlowski-opensource modified the milestones: alpha.6, beta.0 (Feature-complete), alpha.5 Sep 14, 2016
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

1 participant