Skip to content

Commit

Permalink
fix(checkbox): missing focus indicator
Browse files Browse the repository at this point in the history
Adds a ripple when a checkbox is focused.

Referencing angular#421.
  • Loading branch information
crisbeto committed Dec 18, 2016
1 parent 2168d7c commit c4712de
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/lib/checkbox/checkbox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c4712de

Please sign in to comment.