Skip to content

Commit dd0c849

Browse files
authored
fix(item, tab-button): activation behaviour for Ionic theme (#30806)
Issue number: resolves # --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? Currently, in the`ion-item` and `tab-button` components under the Ionic theme, activation behaviors (such as ripple effects and clickability) are applied to both `md` and `ios`, but they should only be applied to`md`. ## What is the new behavior? Activation behavior is now conditional on both theme and mode. The main goal is to ensure that activation only occurs specifically for `md` mode when using the `ionic` theme. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer for more information. -->
1 parent 682e25d commit dd0c849

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

core/src/components/item/item.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { createColorClasses, hostContext, openURL } from '@utils/theme';
88
import { chevronForward } from 'ionicons/icons';
99

1010
import { config } from '../../global/config';
11-
import { getIonTheme } from '../../global/ionic-global';
11+
import { getIonMode, getIonTheme } from '../../global/ionic-global';
1212
import type { AnimationBuilder, Color, CssClassMap, StyleEventDetail } from '../../interface';
1313
import type { RouterDirection } from '../router/utils/interface';
1414

@@ -246,7 +246,13 @@ export class Item implements ComponentInterface, AnchorInterface, ButtonInterfac
246246
}
247247

248248
private canActivate(): boolean {
249-
return this.isClickable() || this.hasCover();
249+
const theme = getIonTheme(this);
250+
const mode = getIonMode(this);
251+
const shouldActivate = this.isClickable() || this.hasCover();
252+
if (theme !== 'ionic') {
253+
return shouldActivate;
254+
}
255+
return mode === 'md' && shouldActivate;
250256
}
251257

252258
private isFocusable(): boolean {

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)