File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
core/src/components/segment Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -78,8 +78,18 @@ export class Segment implements ComponentInterface {
7878 @Prop ( { mutable : true } ) value ?: SegmentValue ;
7979
8080 @Watch ( 'value' )
81- protected valueChanged ( value : SegmentValue | undefined ) {
82- /**
81+ protected valueChanged ( value : SegmentValue | undefined , oldValue ?: SegmentValue | undefined ) {
82+ if ( oldValue !== undefined && value !== undefined ) {
83+ const buttons = this . getButtons ( ) ;
84+ const previous = buttons . find ( button => button . value === oldValue ) ;
85+ const current = buttons . find ( button => button . value === value ) ;
86+
87+ if ( previous && current ) {
88+ this . checkButton ( previous , current ) ;
89+ }
90+ }
91+
92+ /**
8393 * `ionSelect` is emitted every time the value changes (internal or external changes).
8494 * Used by `ion-segment-button` to determine if the button should be checked.
8595 */
@@ -208,7 +218,7 @@ export class Segment implements ComponentInterface {
208218 this . ionChange . emit ( { value } ) ;
209219 }
210220
211- private getButtons ( ) {
221+ private getButtons ( ) : HTMLIonSegmentButtonElement [ ] {
212222 return Array . from ( this . el . querySelectorAll ( 'ion-segment-button' ) ) ;
213223 }
214224
You can’t perform that action at this time.
0 commit comments