ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

Auto hide tabs when keyboard is open

Open RaymondAtivie opened this issue 10 years ago • 61 comments

When the keyboard is opened in a tabs page (position=bottom), the tabs appear on top of the keyboard.

The expected behavior is to hide the tabs when the keyboard is visible

Steps to reproduce:

  1. Create a starter tabs template
  2. Include an ion-input in the page
  3. Run it on a device and focus on the input element

Maybe a CSS class can be added to the page when the keyboard is open (.keyboard-is-open) so that the behavior can be controlled

This issue is for Ionic 2

Cordova CLI: 5.2.0 Gulp version: CLI version 3.9.0 Gulp local: Local version 3.9.1 Ionic Framework Version: 2.0.0-beta.9 Ionic CLI Version: 2.0.0-beta.30 Ionic App Lib Version: 2.0.0-beta.16 OS: Node Version: v4.3.2

RaymondAtivie avatar Jun 24 '16 21:06 RaymondAtivie

Yeah, I assume you're under Android. The old keyboard problem...

I saw a talk on PhoneGap conf of @tlancina about the keyboard and it seems to be a pretty hard issue in general! I can confirm that the bottom tab bar is pushed up upon opening the keyboard in my app under Android, too. But much more worse is covering input fields which are near the bottom. Tim said, one should try to avoid that, but unfortunately there are long lists to edit in my project. I have postponed the whole keyboard topic to wait and see how it plays out in ionic.

Besides, @tlancina, is there a best practice tutorial about using the keyboard in ionic (integrating the ionic keyboard plugin, init/setting event handlers)?

mpaland avatar Jun 25 '16 12:06 mpaland

I am experiencing this issue as well.

tlaverdure avatar Jul 14 '16 18:07 tlaverdure

We are having the same issue in our project too. Any plans regarding this?

masimplo avatar Jul 19 '16 18:07 masimplo

Hey guys, also feeling the pain - any news by any chance?

covveadmin avatar Jul 28 '16 18:07 covveadmin

also need this great feature, tabs and may be even header nice to be able to hide.

theromis avatar Aug 12 '16 07:08 theromis

@jgw96 I noticed you added the enhancement label on this. Since native apps do no behave the same (moving tabs above the keyboard) and the tabs are also limit the actual content real estate to just a couple lines, especially on smaller phones, shouldn't this be consider a more serious issue?

masimplo avatar Aug 12 '16 18:08 masimplo

For people looking for a temporary solution, here's what I did:

TabsComponent constructor:

platform.ready().then(() => {
            Keyboard.onKeyboardShow().subscribe(() => {
                document.body.classList.add('keyboard-is-open');
            });

            Keyboard.onKeyboardHide().subscribe(() => {
                document.body.classList.remove('keyboard-is-open');
            });
});

Inside the CSS:

body.keyboard-is-open ion-tabbar {
  display: none;
}

body.keyboard-is-open scroll-content {
  margin-bottom: 0 !important;
}

This won't work if you have multiple tabs on a page, but I guess you can select them with your CSS directly.

I'm currently running Ionic beta 11

bvx89 avatar Sep 02 '16 12:09 bvx89

any update on this?

RaymondAtivie avatar Oct 07 '16 09:10 RaymondAtivie

@bvx89 Thanks. For the sake of those on Rc0 there's a slight change on the css

body.keyboard-is-open .tabbar {
  display: none;
}

body.keyboard-is-open .scroll-content {
  margin-bottom: 0 !important;
}

No official solution yet tho

RaymondAtivie avatar Oct 07 '16 10:10 RaymondAtivie

Just to mention that enabling Fullscreen mode on Android also fixes this issue for me. This can be done by setting <preference name="Fullscreen" value="true" /> in config.xml, and optionally adding cordova-plugin-fullscreen if you're using a cordova android platform older than v5.0.0.

jeanbaptistevilain avatar Nov 27 '16 15:11 jeanbaptistevilain

Is this going to be fixed in the next version along with the rest of keyboard issues that are going to be fixed (read something stating that about keyboard issues in another thread) or has this fallen between the cracks?

masimplo avatar Nov 27 '16 20:11 masimplo

@RaymondAtivie i have same issue, Is this going to be fixed in the next version?

finalxcode avatar Dec 01 '16 09:12 finalxcode

It's not working for me in RC3. the onKeyboardShow() is never fired...

helderdb avatar Dec 08 '16 10:12 helderdb

+1, i have same issue.

Cordova CLI: 6.3.1 Ionic CLI Version: 2.1.8 Ionic App Lib Version: 2.1.4 ios-deploy version: Not installed ios-sim version: Not installed OS: Windows 8.1 Node Version: v6.4.0 Xcode version: Not installed

Majorhe avatar Dec 20 '16 04:12 Majorhe

I have this same issue, and the workaround posted by @RaymondAtivie isn't working quite right. the tabs are no longer visible, but there appears to be a top border still visible. Anyone else have this issue? I've tried adding box-shadow: none; border-top: none; and still end up with the same top border visible from the tabbar. Any ideas?

payneBrandon avatar Jan 13 '17 16:01 payneBrandon

I've solved this issue by turning ion-content option fullscreen="true" and setting hidden style for tabbar

      var tabbars =     document.getElementsByClassName('tabbar');
      for(var i=0; i<tabbars.length; i++) {
        var node = <HTMLElement>tabbars[i];
        node.style.display = hide === true && 'none' || 'block';
      }

theromis avatar Jan 13 '17 16:01 theromis

I've tried this and still have the same top border showing even though the tabbar is set to display false.

payneBrandon avatar Jan 13 '17 17:01 payneBrandon

@payneBrandon I'm hiding top bar <ion-header *ngIf="isShowHeader()">

theromis avatar Jan 13 '17 17:01 theromis

My ion-tab is at the bottom, so hiding the header doesn't affect it much. I've attached a screenshot of what I'm talking about. The keyboard is shown, the tabs at the bottom are hidden, but it still appears that there is some top boarder line that stays in place if i scroll around. 20170113_102807

payneBrandon avatar Jan 13 '17 17:01 payneBrandon

this bar looks like a part of the form can you share your html code?

theromis avatar Jan 13 '17 17:01 theromis