Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide tabs on keyboard open

I want to hide my tabs when the keyboard is open, and show the tabs again when the keyboard is closed.

I know that I can go just for "AdjustSpan", and thats it, but the problem is that if I do that, the keyboard also hides an input that I have for a chat, because its a footer.

Whats the best way to hide the tabs?

I already tried with [ngClass] in , I tried with Keyboard.disableScroll, and also in app.module.ts using the parameters scrollAssist and autoFocusAssist with false value...

Nothing seems to work.

Any idea of how should I hide the tabs??

Thank you in advance!!

like image 824
Mystearica Avatar asked May 02 '17 13:05

Mystearica


People also ask

How do I hide open tabs?

Instead of the toolbar button, you can use the keyboard shortcut (Alt+Shift+A) to hide and restore tabs.

How do you hide tabs?

Right click on the tab you want to hide. Select Hide.

How do I hide open tabs in Windows 7?

Click on "Preferences" or "Options" to the right of the Panic Button add-on. Select the option to "Hide all windows," then save your preferences. Click on the icon of an orange circle with an exclamation point at any time to hide your browser tabs.

How do I hide tabs in Internet Explorer?

Click the cog icon then click Internet options. Select the Advanced tab, scroll down to Browsing then check the box Hide the button (next to the New Tab button) that opens Microsoft Edge.


2 Answers

You have to add an eventlistener for keyboard-interaction to add (or remove) some css class to the body-tag. In ionic1 the class "hide-on-keyboard-open" was added by default from the framework. In ionic2 you have to walk the "custom-implementation-path". So, here is what you are looking for:

1) Install keyboard-plugin and node_modules as described in ionic2 docs:

ionic plugin add ionic-plugin-keyboard
npm install --save @ionic-native/keyboard

https://ionicframework.com/docs/native/keyboard/

2) Add the plugin to your app.modules.ts

3) Add the desired eventlister withiin the device-ready event in your app.component.ts:

this.platform.ready().then(() => {

        // Okay, so the platform is ready and our plugins are available.
        // Here you can do any higher level native things you might need.
        this.statusBar.styleDefault();

        this.keyboard.onKeyboardShow().subscribe(() => {
            document.body.classList.add('keyboard-is-open');
        });

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

4) Add the class defintion to your app.scss with a additional class-attribute (hideElementOnKeyboardShown)

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

5) Add the class to the desired element, eg an footer, div or sth else:

<ion-footer class="hideElementOnKeyboardShown">
    <button round ion-button (click)="onLogin()"  block>
        <ion-icon name="logo-facebook" padding></ion-icon>
            Login
    </button>
</ion-footer>

6) in this case, put the ion-footer tag within the content-tag, otherwise the calculated viewheight isnt correct when keyboard is shown.

have a nice day!

like image 158
Mica Avatar answered Oct 12 '22 10:10

Mica


just add the following lines to your config.xml..

 <platform name="android">

<preference name="android- 
      manifest/application/activity/@android:windowSoftInputMode" 
   value="adjustPan" />

....
</platform>

What this does is modify the default value that Cordova writes to your AndroidManifest.xml to control the global keyboard input behaviour for your app.

like image 20
Zeeshan Ahmed Avatar answered Oct 12 '22 11:10

Zeeshan Ahmed