Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(radio): radio buttons not being a tab stop and missing focus indication #1731

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a TODO to only show this focus indicator when the focus came from a keyboard event?

Copy link
Member

@jelbourn jelbourn Nov 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pulled down the PR and tested it out; I found that changing the selected radio within a group somewhat quickly (such as when using the keyboard) leaves a trailing grey circle on the radio.
(doesn't occur on master)

<!-- 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]);
}
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being a tab stop is something better covered by an e2e test where we can actually press the tab key, but it is good to have a unit test that asserts we're forwarding the tabIndex property.


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