Skip to content

Commit 6b93bc1

Browse files
committed
fix(tabs): don't add the has-icon class to a tab button if the layout is icon-hide
fixes #5658
1 parent 7ee0b52 commit 6b93bc1

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

ionic/components/tabs/tab-button.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,23 @@ export class TabButton extends Ion {
2929
private hasTitleOnly: boolean;
3030
private hasIconOnly: boolean;
3131
private hasBadge: boolean;
32+
private _layout: string;
3233

3334
@Input() tab: Tab;
3435
@Output() select: EventEmitter<Tab> = new EventEmitter();
3536

3637
constructor(config: Config, elementRef: ElementRef) {
3738
super(elementRef);
3839
this.disHover = (config.get('hoverCSS') === false);
40+
this._layout = config.get('tabbarLayout');
3941
}
4042

4143
ngOnInit() {
4244
this.tab.btn = this;
45+
this._layout = this.tab.parent.tabbarLayout || this._layout;
46+
4347
this.hasTitle = !!this.tab.tabTitle;
44-
this.hasIcon = !!this.tab.tabIcon;
48+
this.hasIcon = !!this.tab.tabIcon && this._layout != 'icon-hide';
4549
this.hasTitleOnly = (this.hasTitle && !this.hasIcon);
4650
this.hasIconOnly = (this.hasIcon && !this.hasTitle);
4751
this.hasBadge = !!this.tab.tabBadge;

ionic/components/tabs/tabs.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ tab-highlight {
159159
right: calc(50% - 30px);
160160
}
161161

162-
[tabbarLayout=icon-hide] .tab-badge,
163162
[tabbarLayout=icon-bottom] .tab-badge,
164163
[tabbarLayout=icon-left] .tab-badge,
165164
[tabbarLayout=icon-right] .tab-badge {

ionic/components/tabs/test/badges/main.html

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333

3434
<!-- Icons right of text -->
35-
<ion-tabs tabbarLayout="icon-right" no-navbar>
35+
<ion-tabs tabbarLayout="icon-right" primary no-navbar>
3636
<ion-tab tabTitle="Recents" tabIcon="call"></ion-tab>
3737
<ion-tab tabTitle="Favorites" tabIcon="heart"></ion-tab>
3838
<ion-tab tabTitle="Settings" tabIcon="settings" tabBadge="1030" tabBadgeStyle="light"></ion-tab>
@@ -45,6 +45,21 @@
4545
<ion-tab tabTitle="Settings" tabIcon="settings"></ion-tab>
4646
</ion-tabs>
4747

48+
<!-- No icons -->
49+
<ion-tabs no-navbar tabbarLayout="icon-hide">
50+
<ion-tab tabTitle="Recents" tabIcon="call" [root]="root"></ion-tab>
51+
<ion-tab tabTitle="Favorites" tabIcon="heart" [root]="root" tabBadge="4"></ion-tab>
52+
<ion-tab tabTitle="Settings" tabIcon="settings" [root]="root"></ion-tab>
53+
</ion-tabs>
54+
55+
56+
<!-- No title -->
57+
<ion-tabs tabbarLayout="title-hide" secondary no-navbar>
58+
<ion-tab tabTitle="Recents" tabIcon="call" [root]="root" tabBadge="7" tabBadgeStyle="light"></ion-tab>
59+
<ion-tab tabTitle="Favorites" tabIcon="heart" [root]="root"></ion-tab>
60+
<ion-tab tabTitle="Settings" tabIcon="settings" [root]="root"></ion-tab>
61+
</ion-tabs>
62+
4863
<!-- Dynamic Badge -->
4964
<ion-tabs tabbarLayout="icon-left" no-navbar>
5065
<ion-tab tabTitle="Recents" tabIcon="call"></ion-tab>

ionic/components/tabs/test/tab-bar-scenarios/main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757

5858
<!-- No title -->
59-
<ion-tabs tabbarLayout="title-hide" no-navbar secondary>
59+
<ion-tabs tabbarLayout="title-hide" secondary no-navbar>
6060
<ion-tab tabTitle="Recents" tabIcon="call" [root]="root"></ion-tab>
6161
<ion-tab tabTitle="Favorites" tabIcon="heart" [root]="root"></ion-tab>
6262
<ion-tab tabTitle="Settings" tabIcon="settings" [root]="root"></ion-tab>

0 commit comments

Comments
 (0)