Skip to content

Commit dd4865a

Browse files
committed
feat(tabButton): Update canActivate logic to consider theme and mode
1 parent 5907566 commit dd4865a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

core/src/components/tab-button/tab-button.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Attributes } from '@utils/helpers';
55
import { inheritAttributes } from '@utils/helpers';
66

77
import { config } from '../../global/config';
8-
import { getIonTheme } from '../../global/ionic-global';
8+
import { getIonMode, getIonTheme } from '../../global/ionic-global';
99
import type {
1010
TabBarChangedEventDetail,
1111
TabButtonClickEventDetail,
@@ -163,10 +163,20 @@ export class TabButton implements ComponentInterface, AnchorInterface {
163163
this.selectTab(ev);
164164
};
165165

166+
private canActivate(): boolean {
167+
const theme = getIonTheme(this);
168+
const mode = getIonMode(this);
169+
if (theme !== 'ionic') {
170+
return true;
171+
}
172+
return mode === 'md';
173+
}
174+
166175
render() {
167176
const { disabled, hasIcon, hasLabel, href, rel, target, layout, selected, tab, inheritedAttributes } = this;
168177
const theme = getIonTheme(this);
169178
const shape = this.getShape();
179+
const canActivate = this.canActivate();
170180
const attrs = {
171181
download: this.download,
172182
href,
@@ -188,7 +198,7 @@ export class TabButton implements ComponentInterface, AnchorInterface {
188198
'tab-has-label-only': hasLabel && !hasIcon,
189199
'tab-has-icon-only': hasIcon && !hasLabel,
190200
[`tab-layout-${layout}`]: true,
191-
'ion-activatable': true,
201+
'ion-activatable': canActivate,
192202
'ion-selectable': true,
193203
[`tab-button-shape-${shape}`]: shape !== undefined,
194204
'ion-focusable': true,

0 commit comments

Comments
 (0)