@@ -71,6 +71,11 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
71
71
72
72
var hasFocus ;
73
73
74
+ //Used to avoid bug in iOS webview where iOS keyboard does not fire
75
+ //mousedown & mouseup events
76
+ //Issue #3699
77
+ var selected ;
78
+
74
79
//create a child scope for the typeahead directive so we are not polluting original scope
75
80
//with typeahead-specific data (matches, query etc.)
76
81
var scope = originalScope . $new ( ) ;
@@ -255,6 +260,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
255
260
var locals = { } ;
256
261
var model , item ;
257
262
263
+ selected = true ;
258
264
locals [ parserResult . itemName ] = item = scope . matches [ activeIdx ] . model ;
259
265
model = parserResult . modelMapper ( originalScope , locals ) ;
260
266
$setModelValue ( originalScope , model ) ;
@@ -283,7 +289,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
283
289
}
284
290
285
291
// if there's nothing selected (i.e. focusFirst) and enter is hit, don't do anything
286
- if ( scope . activeIdx == - 1 && ( evt . which === 13 || evt . which === 9 ) ) {
292
+ if ( scope . activeIdx === - 1 && ( evt . which === 13 || evt . which === 9 ) ) {
287
293
return ;
288
294
}
289
295
@@ -311,7 +317,14 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
311
317
} ) ;
312
318
313
319
element . bind ( 'blur' , function ( evt ) {
320
+ if ( scope . matches . length && scope . activeIdx !== - 1 && ! selected ) {
321
+ selected = true ;
322
+ scope . $apply ( function ( ) {
323
+ scope . select ( scope . activeIdx ) ;
324
+ } ) ;
325
+ }
314
326
hasFocus = false ;
327
+ selected = false ;
315
328
} ) ;
316
329
317
330
// Keep reference to click handler to unbind it.
0 commit comments