Skip to content

Commit 9a27cd9

Browse files
committed
Make sure animation for indeterminate change only if indeterminate value changes
1 parent 437feeb commit 9a27cd9

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/lib/checkbox/checkbox.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ describe('MdCheckbox', () => {
388388
testComponent.isIndeterminate = true;
389389
fixture.detectChanges();
390390

391-
testComponent.isChecked = true;
391+
inputElement.click();
392392
fixture.detectChanges();
393393

394394
expect(checkboxNativeElement.classList).not.toContain(

src/lib/checkbox/checkbox.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,14 @@ export class MdCheckbox implements ControlValueAccessor {
215215
set indeterminate(indeterminate: boolean) {
216216
let changed = indeterminate != this._indeterminate;
217217
this._indeterminate = indeterminate;
218-
if (this._indeterminate) {
219-
this._transitionCheckState(TransitionCheckState.Indeterminate);
220-
} else {
221-
this._transitionCheckState(
222-
this.checked ? TransitionCheckState.Checked : TransitionCheckState.Unchecked);
223-
}
218+
224219
if (changed) {
220+
if (this._indeterminate) {
221+
this._transitionCheckState(TransitionCheckState.Indeterminate);
222+
} else {
223+
this._transitionCheckState(
224+
this.checked ? TransitionCheckState.Checked : TransitionCheckState.Unchecked);
225+
}
225226
this.indeterminateChange.emit(this._indeterminate);
226227
}
227228
}
@@ -377,6 +378,8 @@ export class MdCheckbox implements ControlValueAccessor {
377378
// [checked] bound to it.
378379
if (newState === TransitionCheckState.Checked) {
379380
animSuffix = 'unchecked-checked';
381+
} else if (newState == TransitionCheckState.Indeterminate) {
382+
animSuffix = 'unchecked-indeterminate';
380383
} else {
381384
return '';
382385
}

0 commit comments

Comments
 (0)