Skip to content

Commit 82a9d3e

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

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

src/lib/checkbox/checkbox.spec.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,20 @@ describe('MdCheckbox', () => {
295295
expect(checkboxDebugElement.nativeElement.classList.contains('custom-class')).toBe(true);
296296

297297
});
298+
299+
it('should activate the ripple focused class when the input is focused', () => {
300+
expect(checkboxNativeElement.classList).not.toContain('md-ripple-focused');
301+
302+
checkboxInstance._onInputFocus();
303+
fixture.detectChanges();
304+
305+
expect(checkboxNativeElement.classList).toContain('md-ripple-focused');
306+
307+
checkboxInstance._onInputBlur();
308+
fixture.detectChanges();
309+
310+
expect(checkboxNativeElement.classList).not.toContain('md-ripple-focused');
311+
});
298312
});
299313

300314
describe('state transition css classes', () => {
@@ -555,13 +569,13 @@ describe('MdCheckbox', () => {
555569
/** Simple component for testing a single checkbox. */
556570
@Component({
557571
template: `
558-
<div (click)="parentElementClicked = true" (keyup)="parentElementKeyedUp = true">
559-
<md-checkbox
572+
<div (click)="parentElementClicked = true" (keyup)="parentElementKeyedUp = true">
573+
<md-checkbox
560574
id="simple-check"
561575
[required]="isRequired"
562576
[align]="alignment"
563-
[checked]="isChecked"
564-
[indeterminate]="isIndeterminate"
577+
[checked]="isChecked"
578+
[indeterminate]="isIndeterminate"
565579
[disabled]="isDisabled"
566580
[color]="checkboxColor"
567581
(change)="changeCount = changeCount + 1"
@@ -612,9 +626,9 @@ class MultipleCheckboxes { }
612626
/** Simple test component with tabIndex */
613627
@Component({
614628
template: `
615-
<md-checkbox
616-
[tabindex]="customTabIndex"
617-
[disabled]="isDisabled"
629+
<md-checkbox
630+
[tabindex]="customTabIndex"
631+
[disabled]="isDisabled"
618632
[disableRipple]="disableRipple">
619633
</md-checkbox>`,
620634
})

src/lib/checkbox/checkbox.ts

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

0 commit comments

Comments
 (0)