Skip to content

Commit b51674d

Browse files
committed
refactor(segment-view): separate disabled console error
1 parent d645f24 commit b51674d

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,13 @@ export class SegmentButton implements ComponentInterface, ButtonInterface {
7272
addEventListener(segmentEl, 'ionSelect', this.updateState);
7373
addEventListener(segmentEl, 'ionStyle', this.updateStyle);
7474
}
75-
}
76-
7775

76+
// Prevent buttons from being disabled when associated with segment content
77+
if (this.contentId && this.disabled) {
78+
console.warn(`Segment Button: Segment buttons cannot be disabled when associated with an <ion-segment-content>.`);
79+
this.disabled = false;
80+
}
81+
}
7882

7983
disconnectedCallback() {
8084
const segmentEl = this.segmentEl;
@@ -107,12 +111,6 @@ export class SegmentButton implements ComponentInterface, ButtonInterface {
107111
console.error(`Segment Button: Element with id="${this.contentId}" is not an <ion-segment-content> element.`);
108112
return;
109113
}
110-
111-
// Prevent buttons from being disabled when associated with segment content
112-
if (this.disabled) {
113-
console.warn(`Segment Button: Segment buttons cannot be disabled when associated with an <ion-segment-content>.`);
114-
this.disabled = false;
115-
}
116114
}
117115

118116
private get hasLabel() {

0 commit comments

Comments
 (0)