Skip to content

Commit c4712de

Browse files
committed
fix(checkbox): missing focus indicator
Adds a ripple when a checkbox is focused. Referencing #421.
1 parent 2168d7c commit c4712de

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/lib/checkbox/checkbox.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,20 @@ describe('MdCheckbox', () => {
332332
expect(checkboxDebugElement.nativeElement.classList.contains('custom-class')).toBe(true);
333333

334334
});
335+
336+
it('should activate the ripple focused class when the input is focused', () => {
337+
expect(checkboxNativeElement.classList).not.toContain('md-ripple-focused');
338+
339+
checkboxInstance._onInputFocus();
340+
fixture.detectChanges();
341+
342+
expect(checkboxNativeElement.classList).toContain('md-ripple-focused');
343+
344+
checkboxInstance._onInputBlur();
345+
fixture.detectChanges();
346+
347+
expect(checkboxNativeElement.classList).not.toContain('md-ripple-focused');
348+
});
335349
});
336350

337351
describe('state transition css classes', () => {

src/lib/checkbox/checkbox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class MdCheckboxChange {
7373
'[class.md-checkbox-checked]': 'checked',
7474
'[class.md-checkbox-disabled]': 'disabled',
7575
'[class.md-checkbox-align-end]': 'align == "end"',
76-
'[class.md-checkbox-focused]': '_hasFocus',
76+
'[class.md-ripple-focused]': '_hasFocus', // TODO: should only be triggered by keyboard focus
7777
},
7878
providers: [MD_CHECKBOX_CONTROL_VALUE_ACCESSOR],
7979
encapsulation: ViewEncapsulation.None,

0 commit comments

Comments
 (0)