mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(input): stop ios from hiding keyboard on focus change
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user