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

Commit 5b37bb8

Browse files
committed
fix(typeahead): select match on tab for iOS webview
- Select match on blur if only it has not been selected upon keydown Closes #3762 Fixes #3699
1 parent 7d1c460 commit 5b37bb8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/typeahead/typeahead.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
7878

7979
var hasFocus;
8080

81+
//Used to avoid bug in iOS webview where iOS keyboard does not fire
82+
//mousedown & mouseup events
83+
//Issue #3699
84+
var selected;
85+
8186
//create a child scope for the typeahead directive so we are not polluting original scope
8287
//with typeahead-specific data (matches, query etc.)
8388
var scope = originalScope.$new();
@@ -304,6 +309,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
304309
var locals = {};
305310
var model, item;
306311

312+
selected = true;
307313
locals[parserResult.itemName] = item = scope.matches[activeIdx].model;
308314
model = parserResult.modelMapper(originalScope, locals);
309315
$setModelValue(originalScope, model);
@@ -366,13 +372,15 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
366372
}
367373
});
368374

369-
element.bind('blur', function (evt) {
370-
if (isSelectOnBlur && scope.activeIdx >= 0) {
375+
element.bind('blur', function () {
376+
if (isSelectOnBlur && scope.matches.length && scope.activeIdx !== -1 && !selected) {
377+
selected = true;
371378
scope.$apply(function () {
372379
scope.select(scope.activeIdx);
373380
});
374381
}
375382
hasFocus = false;
383+
selected = false;
376384
});
377385

378386
// Keep reference to click handler to unbind it.

0 commit comments

Comments
 (0)