Skip to content

Commit e09c0a6

Browse files
devversionjelbourn
authored andcommitted
feat(checkbox): expose ripple instance (#9176)
1 parent 2d03af0 commit e09c0a6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/lib/checkbox/checkbox.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ describe('MatCheckbox', () => {
7474
expect(inputElement.checked).toBe(false);
7575
});
7676

77+
it('should expose the ripple instance', () => {
78+
expect(checkboxInstance.ripple).toBeTruthy();
79+
});
80+
7781
it('should add and remove indeterminate state', () => {
7882
expect(checkboxNativeElement.classList).not.toContain('mat-checkbox-checked');
7983
expect(inputElement.checked).toBe(false);

src/lib/checkbox/checkbox.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
177177
/** The native `<input type="checkbox"> element */
178178
@ViewChild('input') _inputElement: ElementRef;
179179

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

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

0 commit comments

Comments
 (0)