fix(segment-button): color property is now reactive if previously undefined (#22405)

resolves #20831
This commit is contained in:
Liam DeBeasi
2020-10-30 16:25:52 -04:00
committed by GitHub
parent 023fb18412
commit 04161c9512
2 changed files with 26 additions and 3 deletions

View File

@ -36,6 +36,22 @@ export class Segment implements ComponentInterface {
* For more information on colors, see [theming](/docs/theming/basics).
*/
@Prop() color?: Color;
@Watch('color')
protected colorChanged(value?: Color, oldValue?: Color) {
/**
* If color is set after not having
* previously been set (or vice versa),
* we need to emit style so the segment-buttons
* can apply their color classes properly.
*/
if (
(oldValue === undefined && value !== undefined) ||
(oldValue !== undefined && value === undefined)
) {
this.emitStyle();
}
}
/**
* If `true`, the user cannot interact with the segment.