mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(segment): fixed segment UI not updating when changing value from view button
Added a test for this. Closes #657
This commit is contained in:
@@ -72,6 +72,9 @@ export class Segment extends Ion {
|
||||
*/
|
||||
writeValue(value) {
|
||||
this.value = !value ? '' : value;
|
||||
for (let button of this.buttons) {
|
||||
button.isActive = (button.value === value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,11 +112,9 @@ export class Segment extends Ion {
|
||||
if (this.buttons.length == 0) {
|
||||
return;
|
||||
}
|
||||
this.buttons.forEach(function(button) {
|
||||
if (button.value === value) {
|
||||
button.isActive = true;
|
||||
}
|
||||
});
|
||||
for (let button of this.buttons) {
|
||||
button.isActive = (button.value === value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
8
ionic/components/segment/test/nav/e2e.ts
Normal file
8
ionic/components/segment/test/nav/e2e.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
it('existing should be selected', function() {
|
||||
element(by.css('.e2eSegmentExistingSegment')).click();
|
||||
});
|
||||
|
||||
it('test should be selected', function() {
|
||||
element(by.css('.e2eSegmentTestButton')).click();
|
||||
});
|
||||
@@ -10,7 +10,7 @@ import {App, Page} from 'ionic/ionic';
|
||||
})
|
||||
class SegmentPage {
|
||||
constructor(fb: FormBuilder) {
|
||||
this.relationship = 'enemies';
|
||||
this.signInType = 'new';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,18 +5,43 @@
|
||||
</ion-navbar>
|
||||
|
||||
<ion-toolbar>
|
||||
<ion-segment [(ng-model)]="relationship">
|
||||
<ion-segment-button value="friends" class="e2eSegmentFriends">
|
||||
Friends
|
||||
<ion-segment [(ng-model)]="signInType">
|
||||
<ion-segment-button value="new">
|
||||
New
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="enemies">
|
||||
Enemies
|
||||
<ion-segment-button value="existing" class="e2eSegmentExistingSegment">
|
||||
Existing
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="test">
|
||||
Test
|
||||
</ion-segment-button>
|
||||
</ion-segment>
|
||||
</ion-toolbar>
|
||||
|
||||
<ion-content padding>
|
||||
<p>Are we friends or enemies? <b>{{ relationship }}</b></p>
|
||||
|
||||
<ion-row>
|
||||
<ion-col>
|
||||
<button type="button" block (click)="signInType='new'">New</button>
|
||||
</ion-col>
|
||||
<ion-col>
|
||||
<button type="button" light block (click)="signInType='existing'">Existing</button>
|
||||
</ion-col>
|
||||
<ion-col>
|
||||
<button type="button" dark block (click)="signInType='test'" class="e2eSegmentTestButton">Test</button>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
|
||||
<div [ng-switch]="signInType">
|
||||
<div *ng-switch-when="'existing'">
|
||||
Signing up as an <b>Existing User</b>.
|
||||
</div>
|
||||
<div *ng-switch-when="'new'">
|
||||
Signing up as a <b>New User</b>.
|
||||
</div>
|
||||
<div *ng-switch-when="'test'">
|
||||
Signing up as a <b>Test User</b>.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</ion-content>
|
||||
|
||||
Reference in New Issue
Block a user