fix(input): stop ios from hiding keyboard on focus change

This commit is contained in:
mhartington
2016-12-06 09:46:03 -05:00
parent 6c0593c80f
commit 5bcd7f2179

View File

@@ -2,7 +2,7 @@ import { Injectable, NgZone } from '@angular/core';
import { Config } from '../config/config';
import { DomController } from './dom-controller';
import { focusOutActiveElement, hasFocusedTextInput, nativeTimeout } from './dom';
import { focusOutActiveElement, hasFocusedTextInput, nativeTimeout, clearNativeTimeout } from './dom';
import { Key } from './key';
@@ -23,19 +23,28 @@ import { Key } from './key';
*/
@Injectable()
export class Keyboard {
private _tmr: any;
constructor(config: Config, private _zone: NgZone, private _dom: DomController) {
_zone.runOutsideAngular(() => {
this.focusOutline(config.get('focusOutline'), document);
window.addEventListener('native.keyboardhide', () => {
// this custom cordova plugin event fires when the keyboard will hide
// useful when the virtual keyboard is closed natively
// https://github.com/driftyco/ionic-plugin-keyboard
if (hasFocusedTextInput()) {
focusOutActiveElement();
}
clearNativeTimeout(this._tmr);
this._tmr = nativeTimeout(() => {
// this custom cordova plugin event fires when the keyboard will hide
// useful when the virtual keyboard is closed natively
// https://github.com/driftyco/ionic-plugin-keyboard
if (hasFocusedTextInput()) {
focusOutActiveElement();
}
}, 80);
});
window.addEventListener('native.keyboardshow', () => {
clearNativeTimeout(this._tmr);
});
});
}