Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Typeahead bug when selecting a "perfect match" from the dropdown #3166

Closed
andertun opened this issue Jan 7, 2015 · 5 comments
Closed

Typeahead bug when selecting a "perfect match" from the dropdown #3166

andertun opened this issue Jan 7, 2015 · 5 comments

Comments

@andertun
Copy link

andertun commented Jan 7, 2015

See this plunker

If the input value is exactly the same as one of the items in the dropdown, and you select that item. The input gets an incorrect state ($invalid = true).

In our case, this prevents the user to submit the form, and it's hard for them to understand why the field is validated as "has error" even though they did nothing wrong.

A "hack" that can be used until this gets fixed would be much appreciated!

@karianna karianna added this to the 0.13 milestone Jan 7, 2015
@zv3
Copy link

zv3 commented Jan 9, 2015

Seems that we both ran into the same issue, I fixed this by using the "typeahead-on-select" directive and a controller like below:

  .controller('TypeaheadCtrl', [function ($scope) {
     $scope.onSelect = function ($item, $model, $label, formInput) {
      formInput.$setValidity('parse', true);
    };
  }])

and then in the html view, within the typeahead input element i added the following directives:

typeahead-on-select="onSelect($item, $model, $label, yourFormName.yourTypeaheadInputName)" ng-controller="TypeaheadCtrl"

I believe this is an angular 1.3.x thing, have not tested it yet with angular 1.2.x

@rpdmiranda
Copy link

I also ran into this issue, it seems that the parser is not called when the selected value is the same as the one in the input field.

@court-jus
Copy link

@zv3 solution ignores the parser totally. Is there a way to call the parser manually ?

@acgentry
Copy link

+1

@dlukez
Copy link
Contributor

dlukez commented Mar 19, 2015

The parser shouldn't need to be called if the view value doesn't change. On the surface I don't see a problem with setting the 'parse' validation key as valid when an item is selected, considering that the same thing is done with the 'editable' validation key also

ayakovlevgh pushed a commit to ayakovlevgh/bootstrap that referenced this issue Mar 24, 2015
When typeahead-editable="false" and we select a perfect
match from the results list, the $parsers aren't called,
which results in the 'parse' error key not being reset.

As with the 'editable' key, we should reset this once
an item is selected because we know we have a valid
model matching the view value.

Closes angular-ui#3166
reda-alaoui added a commit to Cosium/bootstrap that referenced this issue May 4, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants