bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

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

Open andertun opened this issue 11 years ago • 5 comments

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!

andertun avatar Jan 07 '15 16:01 andertun

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

zv3 avatar Jan 09 '15 07:01 zv3

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.

rpdmiranda avatar Jan 10 '15 23:01 rpdmiranda

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

court-jus avatar Feb 18 '15 16:02 court-jus

+1

acgentry avatar Feb 25 '15 18:02 acgentry

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

dlukez avatar Mar 19 '15 01:03 dlukez