Keyboard overlaps the text input when the input is placed inside an <ion-footer>
Short description of the problem:
When an <ion-input type="text"> is placed inside an <ion-toolbar> in an <ion-footer>, the iOS keyboard overlaps text inputs placed in an <ion-footer> and the entire page "jumps" when the input receives focus.

What behavior are you expecting?
I would expect the text input to be shown above the keyboard so the user can see what they're typing, similar to what happens in the Messages app on iOS. I also wouldn't expect the entire page to jump down immediately after the input receives focus.
Steps to reproduce:
- Create a new project with the
blanktemplate - Add the following to
home.html, run the app on iOS, and focus on the text input
<ion-footer>
<ion-toolbar>
<ion-input type="text" placeholder="Add a message..."></ion-input>
</ion-toolbar>
</ion-footer>
Which Ionic Version? 1.x or 2.x 2.x
Run ionic info from terminal/cmd prompt: (paste output below)
Cordova CLI: 6.2.0 Gulp version: CLI version 3.9.1 Gulp local: Local version 3.9.1 Ionic Framework Version: 2.0.0-beta.10 Ionic CLI Version: 2.0.0-beta.31 Ionic App Lib Version: 2.0.0-beta.17 ios-deploy version: 1.8.6 ios-sim version: 5.0.8 OS: Mac OS X El Capitan Node Version: v4.2.3 Xcode version: Xcode 7.3.1 Build version 7D1014
Hello, thanks for opening an issue with us! Would you be able to provide a plunker or repo that demonstrates this issue? Thanks for using Ionic!
Here's a .zip of a project that demonstrates the issue.
(I removed node_modules directory to reduce its size, so you'll need to run npm install)
+1
+1
any news on this?I have the same issue, but not only when the input is in a footer This is a plunker that if built in android device demonstrates the problem http://plnkr.co/edit/GFOUnEeitVpF6o8GSAxU?p=preview
any workaround till this gets fixed?
I am having the same issue. I need a fix ASAP. My app is already in production. I have a text input inside an ion-footer-bar It works fine on android. But on IOS the keyboard covers up the text input area.
@babinc,
My temporary workaround was to replace the <ion-input type="text"> with a plain <input type="text"> and use the following CSS to give it a similar look and feel:
input.messageDraft {
width: 100%;
background-color: transparent;
border: none;
}
I haven't seen any negative side effects using a regular input in place of the ion-input.
@chrskrchr the nice thing about <ion-input> is it allows the user to "blur" the input when tapping outside on iOS.
**Update
Here's the solution I took for <input type="text"/> in the footer-bar not blurring on click-outside.
import {Directive, ElementRef, Output, EventEmitter, HostListener} from '@angular/core';
@Directive({
selector: '[clickOutside]'
})
export class ClickOutsideDirective {
constructor(private _elementRef: ElementRef) {
}
@Output()
public clickOutside = new EventEmitter<MouseEvent>();
@HostListener('document:touchstart', ['$event', '$event.target'])
public onClick(event: MouseEvent, targetElement: HTMLElement): void {
if (!targetElement) {
return;
}
const clickedInside = this._elementRef.nativeElement.contains(targetElement);
if (!clickedInside) {
this.clickOutside.emit(event);
}
}
}
// reference: https://github.com/chliebel/angular2-click-outside
With a slight modification I capture the touchstart event rather than click (works on iOS)
<ion-footer (clickOutside)="onClickOutside()">
import { ClickOutsideDirective } from '../../path/to/directive';
import { Keyboard } from 'ionic-native';
@Component({
directive: [ ClickOutsideDirective ]
})
public onClickOutside() {
Keyboard.close()
}
I am facing the same issue.
i have same issue. but android is good. this problem only appear ios. i have opend this problem. this problem will resolve at beat12 ?????. when set disableScroll is true, then screen donnot shake, but when keyboard appear, the input at ion footer wlll hidden by keyboard.
+1
Solution with changing ion-input to input doesn't work for me (ionic beta 11). My workaround, in app.ts, constructor, platform is ready:
if (platform.is('ios')) {
let
appEl = <HTMLElement>(document.getElementsByTagName('ION-APP')[0]),
appElHeight = appEl.clientHeight;
Keyboard.disableScroll(true);
window.addEventListener('native.keyboardshow', (e) => {
appEl.style.height = (appElHeight - (<any>e).keyboardHeight) + 'px';
});
window.addEventListener('native.keyboardhide', () => {
appEl.style.height = '100%';
});
}
I'm scaling whole app when keyboard shows - it seems be working. I may add few words from me: when I open app on ios and focus on input in footer - keyboard covers footer. When I lose focus clicking on button (it doesn't happen when click on f.e. header) - keyboard hides, footer goes up first (it is placed above keyboard, when it was opened) and then goes again down (it happens really quickly). It looks like bug is connected with triggering. I hope it helps...
I've posted my similar solution here.
this happens to me even I'm just using and in ionic v1
This happens too.
This is work.
<ion-input type="text"> -> <input type="text">
This can't work.
<ion-input type="text"> -> <div contenteditable='true'></div>
Sadly this is still open in 2.0.0 on iOS devices
Hello all! We are currently working with the chrome team on this issue. This is a pretty hard problem to solve because it dives into how keyboards interact with webviews, which is all on the native OS side of things. In the meantime there is this plugin https://github.com/EddyVerbruggen/cordova-plugin-native-keyboard which gives you a native chat input that works around the issue.
I appreciate that there's a plugin that works around the issue, but that plugin is $199USD, and as far as I can tell doesn't have typings for Ionic 2.
I have the same problem.. any solution yet?