bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Typeahead throws exception on exact match

Open Klinton90 opened this issue 9 years ago • 2 comments

Bug description:

When using typeahead with attributes typeahead-select-on-exact="true" and typeahead-show-hint="true" exception is thrown when exact match happens: Cannot read property 'label' of undefined

Link to minimally-working plunker that reproduces the issue:

https://plnkr.co/edit/HrKQIcOy0XjN9BBosdRS?p=preview

Steps to reproduce the issue:

  1. Open DevTools
  2. Type "Alabama" in input field
  3. Error appears in log.

Klinton90 avatar Feb 16 '17 20:02 Klinton90

Same problem here...

I'm looking for a work around in the meanwhile.

jesusmogollon avatar Sep 01 '17 14:09 jesusmogollon

I have changed the getMatchesAsync function, that was the easiest way that I have found to make it work.

          if (showHint) {
                if (scope.matches.length > 0)
                {
                  var firstLabel = scope.matches[0].label;
                  if (angular.isString(inputValue) &&
                    inputValue.length > 0 &&
                    firstLabel.slice(0, inputValue.length).toUpperCase() === inputValue.toUpperCase()) {
                    hintInputElem.val(inputValue + firstLabel.slice(inputValue.length));
                  } else {
                    hintInputElem.val('');
                  }
                }
            }

jesusmogollon avatar Sep 01 '17 14:09 jesusmogollon