diff --git a/packages/components/src/components/segment/__snapshots__/segment.spec.ts.snap b/packages/components/src/components/segment/__snapshots__/segment.spec.ts.snap
index bf96880a50..1c95275796 100644
--- a/packages/components/src/components/segment/__snapshots__/segment.spec.ts.snap
+++ b/packages/components/src/components/segment/__snapshots__/segment.spec.ts.snap
@@ -15,6 +15,8 @@ exports[`Segment should match standard snapshot 1`] = `
- Label
+
+ Label
+
`;
diff --git a/packages/components/src/components/segment/readme.md b/packages/components/src/components/segment/readme.md
index bc5a198334..249d97f3ad 100644
--- a/packages/components/src/components/segment/readme.md
+++ b/packages/components/src/components/segment/readme.md
@@ -7,24 +7,24 @@
## Properties
-| Property | Attribute | Description | Type | Default |
-| ---------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------- | -------------- |
-| `adjacentSiblings` | `adjacent-siblings` | | `"left" \| "leftright" \| "right"` | `undefined` |
-| `ariaDescriptionTranslation` | `aria-description-translation` | a11y text for getting meaningful value. `$buttonNumber` and `$selected` are template variables and will be replaces by their corresponding properties. | `string` | `'$selected'` |
-| `ariaLabelSegment` | `aria-label-segment` | (optional) aria-label attribute needed for icon-only segments | `string` | `undefined` |
-| `ariaLangDeselected` | `aria-lang-deselected` | (optional) translation of 'deselected | `string` | `'deselected'` |
-| `ariaLangSelected` | `aria-lang-selected` | (optional) translation of 'selected | `string` | `'selected'` |
-| `disabled` | `disabled` | (optional) If `true`, the segment is disabled | `boolean` | `false` |
-| `hasIcon` | `has-icon` | (optional) position within group | `boolean` | `undefined` |
-| `iconOnly` | `icon-only` | (optional) position within group | `boolean` | `undefined` |
-| `position` | `position` | (optional) position within group | `number` | `undefined` |
-| `segmentId` | `segment-id` | (optional) segment's id | `string` | `undefined` |
-| `selected` | `selected` | (optional) If `true`, the segment is selected | `boolean` | `false` |
-| `selectedIndex` | `selected-index` | (optional) the index of the currently selected segment in the segmented-button | `string` | `undefined` |
-| `size` | `size` | (optional) The size of the segment | `"large" \| "medium" \| "small"` | `'small'` |
-| `styles` | `styles` | (optional) Injected CSS styles | `string` | `undefined` |
-| `textOnly` | `text-only` | (optional) position within group | `boolean` | `undefined` |
-| `width` | `width` | (optional) Segment width set to ensure that all segments have the same width | `string` | `undefined` |
+| Property | Attribute | Description | Type | Default |
+| ---------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------- | ------------------ |
+| `adjacentSiblings` | `adjacent-siblings` | | `"left" \| "leftright" \| "right"` | `undefined` |
+| `ariaDescriptionTranslation` | `aria-description-translation` | a11y text for getting meaningful value. `$buttonNumber` and `$selected` are template variables and will be replaces by their corresponding properties. | `string` | `'$selected'` |
+| `ariaLabelSegment` | `aria-label-segment` | (optional) aria-label attribute needed for icon-only segments | `string` | `undefined` |
+| `ariaLangDeselected` | `aria-lang-deselected` | (optional) translation of 'deselected | `string` | `'deselected'` |
+| `ariaLangSelected` | `aria-lang-selected` | (optional) translation of 'selected | `string` | `'selected'` |
+| `disabled` | `disabled` | (optional) If `true`, the segment is disabled | `boolean` | `false` |
+| `hasIcon` | `has-icon` | (optional) position within group | `boolean` | `undefined` |
+| `iconOnly` | `icon-only` | (optional) position within group | `boolean` | `undefined` |
+| `position` | `position` | (optional) position within group | `number` | `undefined` |
+| `segmentId` | `segment-id` | (optional) segment's id | `string` | `'segment-' + i++` |
+| `selected` | `selected` | (optional) If `true`, the segment is selected | `boolean` | `false` |
+| `selectedIndex` | `selected-index` | (optional) the index of the currently selected segment in the segmented-button | `string` | `undefined` |
+| `size` | `size` | (optional) The size of the segment | `"large" \| "medium" \| "small"` | `'small'` |
+| `styles` | `styles` | (optional) Injected CSS styles | `string` | `undefined` |
+| `textOnly` | `text-only` | (optional) position within group | `boolean` | `undefined` |
+| `width` | `width` | (optional) Segment width set to ensure that all segments have the same width | `string` | `undefined` |
## Events
diff --git a/packages/components/src/components/segment/segment.tsx b/packages/components/src/components/segment/segment.tsx
index c2daf67c0c..67b45ffa82 100644
--- a/packages/components/src/components/segment/segment.tsx
+++ b/packages/components/src/components/segment/segment.tsx
@@ -38,7 +38,7 @@ export class Segment {
/** (optional) If `true`, the segment is disabled */
@Prop() disabled?: boolean = false;
/** (optional) segment's id */
- @Prop({ reflect: true, mutable: true }) segmentId?: string;
+ @Prop({ reflect: true }) segmentId?: string = 'segment-' + i++;
/** (optional) aria-label attribute needed for icon-only segments */
@Prop() ariaLabelSegment: string;
/** (optional) Segment width set to ensure that all segments have the same width */
@@ -84,13 +84,10 @@ export class Segment {
async setFocus() {
this.focusableElement.focus();
}
-
componentWillLoad() {
- if (this.segmentId == null) {
- this.segmentId = 'segment-' + i++;
- }
+ this.handleIcon();
}
- componentDidUpdate() {
+ componentWillUpdate() {
this.handleIcon();
}
diff --git a/packages/components/src/components/segmented-button/__snapshots__/segmented-button.spec.ts.snap b/packages/components/src/components/segmented-button/__snapshots__/segmented-button.spec.ts.snap
index 41c565086d..82e5bc5170 100644
--- a/packages/components/src/components/segmented-button/__snapshots__/segmented-button.spec.ts.snap
+++ b/packages/components/src/components/segmented-button/__snapshots__/segmented-button.spec.ts.snap
@@ -3,7 +3,7 @@
exports[`SegmentedButton should match selected button snapshot 1`] = `
-
+
@@ -19,7 +19,7 @@ exports[`SegmentedButton should match selected button snapshot 1`] = `
exports[`SegmentedButton should match standard snapshot 1`] = `
-