Skip to content

Commit 7ddacf1

Browse files
author
Tanner Reits
committed
fix(segment): remove segment-view-id
1 parent 0f2d565 commit 7ddacf1

File tree

4 files changed

+9
-33
lines changed

4 files changed

+9
-33
lines changed

core/src/components.d.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2678,10 +2678,6 @@ export namespace Components {
26782678
* If `true`, the segment buttons will overflow and the user can swipe to see them. In addition, this will disable the gesture to drag the indicator between the buttons in order to swipe to see hidden buttons.
26792679
*/
26802680
"scrollable": boolean;
2681-
/**
2682-
* The `id` of the segment view that this segment component should be linked to.
2683-
*/
2684-
"segmentViewId"?: string;
26852681
/**
26862682
* If `true`, navigating to an `ion-segment-button` with the keyboard will focus and select the element. If `false`, keyboard navigation will only focus the `ion-segment-button` element.
26872683
*/
@@ -7487,10 +7483,6 @@ declare namespace LocalJSX {
74877483
* If `true`, the segment buttons will overflow and the user can swipe to see them. In addition, this will disable the gesture to drag the indicator between the buttons in order to swipe to see hidden buttons.
74887484
*/
74897485
"scrollable"?: boolean;
7490-
/**
7491-
* The `id` of the segment view that this segment component should be linked to.
7492-
*/
7493-
"segmentViewId"?: string;
74947486
/**
74957487
* If `true`, navigating to an `ion-segment-button` with the keyboard will focus and select the element. If `false`, keyboard navigation will only focus the `ion-segment-button` element.
74967488
*/

core/src/components/segment/segment.tsx

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,6 @@ export class Segment implements ComponentInterface {
132132
*/
133133
@Prop() selectOnFocus = false;
134134

135-
/**
136-
* The `id` of the segment view that this segment component should be linked to.
137-
*/
138-
@Prop() segmentViewId?: string;
139-
140135
/**
141136
* Emitted when the value property has changed and any dragging pointer has been released from `ion-segment`.
142137
*
@@ -366,23 +361,13 @@ export class Segment implements ComponentInterface {
366361
}
367362

368363
private getSegmentView() {
369-
if (!this.segmentViewId) {
370-
return null;
371-
}
372-
373-
const segmentViewEl = document.getElementById(this.segmentViewId);
374-
375-
if (!segmentViewEl) {
376-
console.warn(`Segment: Unable to find 'ion-segment-view' with id="${this.segmentViewId}"`);
377-
return null;
378-
}
379-
380-
if (segmentViewEl.tagName !== 'ION-SEGMENT-VIEW') {
381-
console.warn(`Segment: Element with id="${this.segmentViewId}" is not an <ion-segment-view> element.`);
382-
return null;
383-
}
384-
385-
return segmentViewEl as HTMLIonSegmentViewElement;
364+
const buttons = this.getButtons();
365+
// Get the first button with a contentId
366+
const firstContentId = buttons.find((button: HTMLIonSegmentButtonElement) => button.contentId);
367+
// Get the segment content with an id matching the button's contentId
368+
const segmentContent = document.querySelector(`ion-segment-content[id="${firstContentId?.contentId}"]`);
369+
// Return the segment view for that matching segment content
370+
return segmentContent?.closest('ion-segment-view');
386371
}
387372

388373
@Listen('ionSegmentViewScroll', { target: 'body' })

packages/angular/src/directives/proxies.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,14 +1952,14 @@ This event will not emit when programmatically setting the `value` property.
19521952

19531953

19541954
@ProxyCmp({
1955-
inputs: ['color', 'disabled', 'mode', 'scrollable', 'segmentViewId', 'selectOnFocus', 'swipeGesture', 'value']
1955+
inputs: ['color', 'disabled', 'mode', 'scrollable', 'selectOnFocus', 'swipeGesture', 'value']
19561956
})
19571957
@Component({
19581958
selector: 'ion-segment',
19591959
changeDetection: ChangeDetectionStrategy.OnPush,
19601960
template: '<ng-content></ng-content>',
19611961
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
1962-
inputs: ['color', 'disabled', 'mode', 'scrollable', 'segmentViewId', 'selectOnFocus', 'swipeGesture', 'value'],
1962+
inputs: ['color', 'disabled', 'mode', 'scrollable', 'selectOnFocus', 'swipeGesture', 'value'],
19631963
})
19641964
export class IonSegment {
19651965
protected el: HTMLElement;

packages/vue/src/proxies.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,6 @@ export const IonSegment = /*@__PURE__*/ defineContainer<JSX.IonSegment, JSX.IonS
738738
'swipeGesture',
739739
'value',
740740
'selectOnFocus',
741-
'segmentViewId',
742741
'ionChange',
743742
'ionSelect',
744743
'ionStyle'

0 commit comments

Comments
 (0)