Skip to content

Commit

Permalink
fix(radio): radio buttons not being a tab stop and missing focus indi…
Browse files Browse the repository at this point in the history
…cation

* Fixes the radio buttons not being tabable.
* Adds focus indication to the radio buttons.

Referencing angular#421.
  • Loading branch information
crisbeto committed Dec 2, 2016
1 parent dfc580d commit 2b704bb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 73 deletions.
72 changes: 0 additions & 72 deletions scripts/browserstack/start_tunnel.sh

This file was deleted.

3 changes: 2 additions & 1 deletion src/lib/radio/radio.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!-- TODO(jelbourn): render the radio on either side of the content -->
<!-- TODO(mtlin): Evaluate trade-offs of using native radio vs. cost of additional bindings. -->
<label [attr.for]="inputId" class="md-radio-label">
<!-- TODO(crisbeto): only show focus indication if focus came from a keyboard event -->
<label [attr.for]="inputId" class="md-radio-label" [class.md-ripple-focused]="_isFocused">
<!-- The actual 'radio' part of the control. -->
<div class="md-radio-container">
<div class="md-radio-outer-circle"></div>
Expand Down
18 changes: 18 additions & 0 deletions src/lib/radio/radio.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,24 @@ describe('MdRadio', () => {
expect(document.activeElement).toBe(fruitRadioNativeInputs[i]);
}
});

it('should add a ripple when the native input element is focused', () => {
let hostElement = seasonRadioInstances[0].getHostElement() as HTMLElement;
let input = hostElement.querySelector('input') as HTMLInputElement;
let label = hostElement.querySelector('label') as HTMLLabelElement;

expect(label.classList).not.toContain('md-ripple-focused');

dispatchEvent('focus', input);
fixture.detectChanges();

expect(label.classList).toContain('md-ripple-focused');

dispatchEvent('blur', input);
fixture.detectChanges();

expect(label.classList).not.toContain('md-ripple-focused');
});
});
});

Expand Down

0 comments on commit 2b704bb

Please sign in to comment.