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

Commit

Permalink
fix(typeahead): plug in front of existing parsers
Browse files Browse the repository at this point in the history
Closes #863
  • Loading branch information
pkozlowski-opensource committed Aug 24, 2013
1 parent ed5f979 commit 80cef61
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/typeahead/test/typeahead.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,21 @@ describe('typeahead tests', function () {

expect(inputEl.val()).toEqual('Alaska');
});

it('issue 863 - it should work correctly with input type="email"', function () {

$scope.emails = ['[email protected]', '[email protected]'];
var element = prepareInputEl("<div><input type='email' ng-model='email' typeahead='email for email in emails | filter:$viewValue'></div>");
var inputEl = findInput(element);

changeInputValueTo(element, 'bar');
expect(element).toBeOpenWithActive(1, 0);

triggerKeyDown(element, 13);

expect($scope.email).toEqual('[email protected]');
expect(inputEl.val()).toEqual('[email protected]');
});
});

describe('input formatting', function () {
Expand Down
2 changes: 1 addition & 1 deletion src/typeahead/typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position'])

//plug into $parsers pipeline to open a typeahead on view changes initiated from DOM
//$parsers kick-in on all the changes coming from the view as well as manually triggered by $setViewValue
modelCtrl.$parsers.push(function (inputValue) {
modelCtrl.$parsers.unshift(function (inputValue) {

resetMatches();
if (inputValue && inputValue.length >= minSearch) {
Expand Down

0 comments on commit 80cef61

Please sign in to comment.