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

Commit 80cef61

Browse files
fix(typeahead): plug in front of existing parsers
Closes #863
1 parent ed5f979 commit 80cef61

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/typeahead/test/typeahead.spec.js

+15
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,21 @@ describe('typeahead tests', function () {
363363

364364
expect(inputEl.val()).toEqual('Alaska');
365365
});
366+
367+
it('issue 863 - it should work correctly with input type="email"', function () {
368+
369+
$scope.emails = ['foo@host.com', 'bar@host.com'];
370+
var element = prepareInputEl("<div><input type='email' ng-model='email' typeahead='email for email in emails | filter:$viewValue'></div>");
371+
var inputEl = findInput(element);
372+
373+
changeInputValueTo(element, 'bar');
374+
expect(element).toBeOpenWithActive(1, 0);
375+
376+
triggerKeyDown(element, 13);
377+
378+
expect($scope.email).toEqual('bar@host.com');
379+
expect(inputEl.val()).toEqual('bar@host.com');
380+
});
366381
});
367382

368383
describe('input formatting', function () {

src/typeahead/typeahead.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position'])
143143

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

148148
resetMatches();
149149
if (inputValue && inputValue.length >= minSearch) {

0 commit comments

Comments
 (0)