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: 4 additions & 0 deletions src/lib/checkbox/checkbox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ describe('MatCheckbox', () => {
expect(inputElement.checked).toBe(false);
});

it('should expose the ripple instance', () => {
expect(checkboxInstance.ripple).toBeTruthy();
});

it('should add and remove indeterminate state', () => {
expect(checkboxNativeElement.classList).not.toContain('mat-checkbox-checked');
expect(inputElement.checked).toBe(false);
Expand Down
6 changes: 3 additions & 3 deletions src/lib/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
/** The native `<input type="checkbox"> element */
@ViewChild('input') _inputElement: ElementRef;

/** Called when the checkbox is blurred. Needed to properly implement ControlValueAccessor. */
@ViewChild(MatRipple) _ripple: MatRipple;
/** Reference to the ripple instance of the checkbox. */
@ViewChild(MatRipple) ripple: MatRipple;

/** Ripple configuration for the mouse ripples and focus indicators. */
_rippleConfig: RippleConfig = {centered: true, radius: 25, speedFactor: 1.5};
Expand Down Expand Up @@ -346,7 +346,7 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
/** Function is called whenever the focus changes for the input element. */
private _onInputFocusChange(focusOrigin: FocusOrigin) {
if (!this._focusRipple && focusOrigin === 'keyboard') {
this._focusRipple = this._ripple.launch(0, 0, {persistent: true, ...this._rippleConfig});
this._focusRipple = this.ripple.launch(0, 0, {persistent: true, ...this._rippleConfig});
} else if (!focusOrigin) {
this._removeFocusRipple();
this.onTouched();
Expand Down