Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/checkbox/checkbox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,11 @@ describe('MdCheckbox', () => {

describe('state transition css classes', () => {
it('should transition unchecked -> checked -> unchecked', () => {
testComponent.isChecked = true;
inputElement.click();
fixture.detectChanges();
expect(checkboxNativeElement.classList).toContain('mat-checkbox-anim-unchecked-checked');

testComponent.isChecked = false;
inputElement.click();
fixture.detectChanges();
expect(checkboxNativeElement.classList)
.not.toContain('mat-checkbox-anim-unchecked-checked');
Expand Down
19 changes: 11 additions & 8 deletions src/lib/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ export class MdCheckbox implements ControlValueAccessor {
this.indeterminateChange.emit(this._indeterminate);
}
this._checked = checked;
this._transitionCheckState(
this._checked ? TransitionCheckState.Checked : TransitionCheckState.Unchecked);
this._changeDetectorRef.markForCheck();
}
}
Expand All @@ -217,13 +215,14 @@ export class MdCheckbox implements ControlValueAccessor {
set indeterminate(indeterminate: boolean) {
let changed = indeterminate != this._indeterminate;
this._indeterminate = indeterminate;
if (this._indeterminate) {
this._transitionCheckState(TransitionCheckState.Indeterminate);
} else {
this._transitionCheckState(
this.checked ? TransitionCheckState.Checked : TransitionCheckState.Unchecked);
}

if (changed) {
if (this._indeterminate) {
this._transitionCheckState(TransitionCheckState.Indeterminate);
} else {
this._transitionCheckState(
this.checked ? TransitionCheckState.Checked : TransitionCheckState.Unchecked);
}
this.indeterminateChange.emit(this._indeterminate);
}
}
Expand Down Expand Up @@ -348,6 +347,8 @@ export class MdCheckbox implements ControlValueAccessor {

if (!this.disabled) {
this.toggle();
this._transitionCheckState(
this._checked ? TransitionCheckState.Checked : TransitionCheckState.Unchecked);

// Emit our custom change event if the native input emitted one.
// It is important to only emit it, if the native input triggered one, because
Expand Down Expand Up @@ -379,6 +380,8 @@ export class MdCheckbox implements ControlValueAccessor {
// [checked] bound to it.
if (newState === TransitionCheckState.Checked) {
animSuffix = 'unchecked-checked';
} else if (newState == TransitionCheckState.Indeterminate) {
animSuffix = 'unchecked-indeterminate';
} else {
return '';
}
Expand Down