From c4712deb06e4a41562f2acc2f812a46e25df17c2 Mon Sep 17 00:00:00 2001 From: crisbeto Date: Fri, 4 Nov 2016 19:04:24 +0100 Subject: [PATCH] fix(checkbox): missing focus indicator Adds a ripple when a checkbox is focused. Referencing #421. --- src/lib/checkbox/checkbox.spec.ts | 14 ++++++++++++++ src/lib/checkbox/checkbox.ts | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/lib/checkbox/checkbox.spec.ts b/src/lib/checkbox/checkbox.spec.ts index ac7e3e83c3d7..1cc91dcdb906 100644 --- a/src/lib/checkbox/checkbox.spec.ts +++ b/src/lib/checkbox/checkbox.spec.ts @@ -332,6 +332,20 @@ describe('MdCheckbox', () => { expect(checkboxDebugElement.nativeElement.classList.contains('custom-class')).toBe(true); }); + + it('should activate the ripple focused class when the input is focused', () => { + expect(checkboxNativeElement.classList).not.toContain('md-ripple-focused'); + + checkboxInstance._onInputFocus(); + fixture.detectChanges(); + + expect(checkboxNativeElement.classList).toContain('md-ripple-focused'); + + checkboxInstance._onInputBlur(); + fixture.detectChanges(); + + expect(checkboxNativeElement.classList).not.toContain('md-ripple-focused'); + }); }); describe('state transition css classes', () => { diff --git a/src/lib/checkbox/checkbox.ts b/src/lib/checkbox/checkbox.ts index ad1332117327..ce3467c6a0ec 100644 --- a/src/lib/checkbox/checkbox.ts +++ b/src/lib/checkbox/checkbox.ts @@ -73,7 +73,7 @@ export class MdCheckboxChange { '[class.md-checkbox-checked]': 'checked', '[class.md-checkbox-disabled]': 'disabled', '[class.md-checkbox-align-end]': 'align == "end"', - '[class.md-checkbox-focused]': '_hasFocus', + '[class.md-ripple-focused]': '_hasFocus', // TODO: should only be triggered by keyboard focus }, providers: [MD_CHECKBOX_CONTROL_VALUE_ACCESSOR], encapsulation: ViewEncapsulation.None,