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

Detect typeahead validity with formGroup #788

Closed
natcohen opened this issue Sep 22, 2016 · 3 comments
Closed

Detect typeahead validity with formGroup #788

natcohen opened this issue Sep 22, 2016 · 3 comments

Comments

@natcohen
Copy link

natcohen commented Sep 22, 2016

It is impossible to detect when a typeahead is valid (meaning that an item as been selected or match one of the list - and not just a random input). The input becomes valid whenever something is inserted. I'm using a model driven approach to forms.

Angular: 2.0.0

ng-bootstrap: 1.0.0-alpha.5

Bootstrap: 4-alpha 4

@pkozlowski-opensource
Copy link
Member

IMO there is a limited set of validation rules when it comes typeaheads - required is probably the most common one (I'm saying this since the whole idea of a typeahead is to present users with a set of valid matches - there is no point of presenting for selection an option that is invalid).

As of today a field that has a typeahead on it is editable by default (by "editable" I mean that whatever a user types in the input field gets propagated to the model). So in this sense as soon as a user starts typing something the field is "valid" (when it comes to the required validator rule).

What you are really looking for is the equivalent of the typeahead-editable option from http://angular-ui.github.io/bootstrap/#/typeahead. by switching on this option you could enforce a rule bu which users can only select an entry from the autcomplete. No selection = no model update => field not valid (from the "required") point of view.

@natcohen does the above make sense? Of so I'm going to rename this issue. BTW, we are planning to add editable option anyway.

@natcohen
Copy link
Author

@pkozlowski-opensource Yes, this is exactly what I meant (typeahead-editable = false)

@pkozlowski-opensource
Copy link
Member

this is exactly what I meant (typeahead-editable = false)

@natcohen well, the good news is that it just landed in master :-) Cutting a release today.

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