MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / activate

Method activate

core/src/components/segment/segment.tsx:288–310  ·  view source on GitHub ↗
(detail: GestureDetail)

Source from the content-addressed store, hash-verified

286 }
287
288 private activate(detail: GestureDetail) {
289 const clicked = detail.event.target as HTMLIonSegmentButtonElement;
290 const buttons = this.getButtons();
291 const checked = buttons.find((button) => button.value === this.value);
292
293 // Make sure we are only checking for activation on a segment button
294 // since disabled buttons will get the click on the segment
295 if (clicked.tagName !== 'ION-SEGMENT-BUTTON') {
296 return;
297 }
298
299 // If there are no checked buttons, set the current button to checked
300 if (!checked) {
301 this.value = clicked.value;
302 this.setCheckedClasses();
303 }
304
305 // If the gesture began on the clicked button with the indicator
306 // then we should activate the indicator
307 if (this.value === clicked.value) {
308 this.setActivated(true);
309 }
310 }
311
312 private getIndicator(button: HTMLIonSegmentButtonElement): HTMLDivElement | null {
313 const root = button.shadowRoot || button;

Callers 1

onStartMethod · 0.95

Calls 3

getButtonsMethod · 0.95
setCheckedClassesMethod · 0.95
setActivatedMethod · 0.95

Tested by

no test coverage detected