Skip to content

Commit 5bcd7f2

Browse files
committed
fix(input): stop ios from hiding keyboard on focus change
1 parent 6c0593c commit 5bcd7f2

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/util/keyboard.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Injectable, NgZone } from '@angular/core';
22

33
import { Config } from '../config/config';
44
import { DomController } from './dom-controller';
5-
import { focusOutActiveElement, hasFocusedTextInput, nativeTimeout } from './dom';
5+
import { focusOutActiveElement, hasFocusedTextInput, nativeTimeout, clearNativeTimeout } from './dom';
66
import { Key } from './key';
77

88

@@ -23,19 +23,28 @@ import { Key } from './key';
2323
*/
2424
@Injectable()
2525
export class Keyboard {
26+
private _tmr: any;
2627

2728
constructor(config: Config, private _zone: NgZone, private _dom: DomController) {
2829
_zone.runOutsideAngular(() => {
2930
this.focusOutline(config.get('focusOutline'), document);
3031

3132
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);
3842
});
43+
44+
window.addEventListener('native.keyboardshow', () => {
45+
clearNativeTimeout(this._tmr);
46+
});
47+
3948
});
4049
}
4150

0 commit comments

Comments
 (0)