From 5bcd7f2179d0fac054eae1c60f470f8e732b5c8e Mon Sep 17 00:00:00 2001 From: mhartington Date: Tue, 6 Dec 2016 09:46:03 -0500 Subject: [PATCH] fix(input): stop ios from hiding keyboard on focus change --- src/util/keyboard.ts | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/util/keyboard.ts b/src/util/keyboard.ts index 35756a22a67..45e592adcf2 100644 --- a/src/util/keyboard.ts +++ b/src/util/keyboard.ts @@ -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); + }); + }); }