@@ -2,7 +2,7 @@ import { Injectable, NgZone } from '@angular/core';
2
2
3
3
import { Config } from '../config/config' ;
4
4
import { DomController } from './dom-controller' ;
5
- import { focusOutActiveElement , hasFocusedTextInput , nativeTimeout } from './dom' ;
5
+ import { focusOutActiveElement , hasFocusedTextInput , nativeTimeout , clearNativeTimeout } from './dom' ;
6
6
import { Key } from './key' ;
7
7
8
8
@@ -23,19 +23,28 @@ import { Key } from './key';
23
23
*/
24
24
@Injectable ( )
25
25
export class Keyboard {
26
+ private _tmr : any ;
26
27
27
28
constructor ( config : Config , private _zone : NgZone , private _dom : DomController ) {
28
29
_zone . runOutsideAngular ( ( ) => {
29
30
this . focusOutline ( config . get ( 'focusOutline' ) , document ) ;
30
31
31
32
window . addEventListener ( 'native.keyboardhide' , ( ) => {
32
- // this custom cordova plugin event fires when the keyboard will hide
33
- // useful when the virtual keyboard is closed natively
34
- // https://github.com/driftyco/ionic-plugin-keyboard
35
- if ( hasFocusedTextInput ( ) ) {
36
- focusOutActiveElement ( ) ;
37
- }
33
+ clearNativeTimeout ( this . _tmr ) ;
34
+ this . _tmr = nativeTimeout ( ( ) => {
35
+ // this custom cordova plugin event fires when the keyboard will hide
36
+ // useful when the virtual keyboard is closed natively
37
+ // https://github.com/driftyco/ionic-plugin-keyboard
38
+ if ( hasFocusedTextInput ( ) ) {
39
+ focusOutActiveElement ( ) ;
40
+ }
41
+ } , 80 ) ;
38
42
} ) ;
43
+
44
+ window . addEventListener ( 'native.keyboardshow' , ( ) => {
45
+ clearNativeTimeout ( this . _tmr ) ;
46
+ } ) ;
47
+
39
48
} ) ;
40
49
}
41
50
0 commit comments