isleofcode/ember-cordova-keyboard

document.body height not being reset when keyboard closes after typing into multiple inputs

Opened this issue · 1 comments

This looks like an issue with ionic-plugin-keyboard, but I thought it could be mitigated here.

I noticed that when entering text into an input and then closing the keyboard, everything works fine. But when entering text into an input, selecting another input, and then closing the keyboard, the body height stays small (as if the keyboard is still open).

I added a few console.log statements and noticed that the native.keyboardshow event is firing twice after the native.keyboardhide event when switching inputs. With the way ember-cordova-keyboard is coded to handle the body resizing, this._height is being reset to the initial body height, and then set to the calculated height because of the subsequent native.keyboardshow event that fires.

I think by just wrapping the line of code that sets this._height in a condition to check for isVisible this issue would be mitigated:

if (!this._keyboard.isVisible) {
  this._height = document.body.style.height || '';
}

Here is a screen capture of the issue:
cordova-keyboard-bug

Thanks for reporting. I'm going to give this a test as well, but if you have a working case you are more than welcome to PR. Thanks!