Skip to content

Commit

Permalink
fix(tabs): hide tabbar when keyboard opens
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed May 9, 2017
1 parent 015187a commit 7baa270
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/components/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Config } from '../../config/config';
import { DeepLinker } from '../../navigation/deep-linker';
import { Ion } from '../ion';
import { isBlank, assert } from '../../util/util';
import { Keyboard } from '../../platform/keyboard';
import { Tabs as ITabs } from '../../navigation/nav-interfaces';
import { NavController } from '../../navigation/nav-controller';
import { NavControllerBase } from '../../navigation/nav-controller-base';
Expand Down Expand Up @@ -151,7 +152,7 @@ import { ViewController } from '../../navigation/view-controller';
@Component({
selector: 'ion-tabs',
template:
'<div class="tabbar" role="tablist" #tabbar>' +
'<div class="tabbar" role="tablist" #tabbar [hidden]="_tabbarVisible">' +
'<a *ngFor="let t of _tabs" [tab]="t" class="tab-button" role="tab" href="#" (ionSelect)="select(t)"></a>' +
'<div class="tab-highlight"></div>' +
'</div>' +
Expand All @@ -177,6 +178,10 @@ export class Tabs extends Ion implements AfterViewInit, RootNode, ITabs {
_selectHistory: string[] = [];
/** @internal */
_resizeObs: any;
/** @internal */
_keyboardObs: any;
/** @internal */
_tabbarVisible = true;

/**
* @input {number} The default selected tab index when first loaded. If a selected index isn't provided then it will use `0`, the first tab.
Expand Down Expand Up @@ -231,7 +236,8 @@ export class Tabs extends Ion implements AfterViewInit, RootNode, ITabs {
elementRef: ElementRef,
private _plt: Platform,
renderer: Renderer,
private _linker: DeepLinker
private _linker: DeepLinker,
keyboard: Keyboard
) {
super(config, elementRef, renderer, 'tabs');

Expand Down Expand Up @@ -261,9 +267,16 @@ export class Tabs extends Ion implements AfterViewInit, RootNode, ITabs {
viewCtrl._setContent(this);
viewCtrl._setContentRef(elementRef);
}

if (config.getBoolean('keyboardResizes', false)) {
keyboard.didChange.subscribe((visible: boolean) => {
this._tabbarVisible = visible
});
}
}

ngOnDestroy() {
this._keyboardObs && this._keyboardObs.unsubscribe();
this._resizeObs && this._resizeObs.unsubscribe();
this.parent.unregisterChildNav(this);
}
Expand Down

0 comments on commit 7baa270

Please sign in to comment.