-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
<!-- The actual 'radio' part of the control. --> | ||
<div class="md-radio-container"> | ||
<div class="md-radio-outer-circle"></div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -574,6 +574,24 @@ describe('MdRadio', () => { | |
expect(document.activeElement).toBe(fruitRadioNativeInputs[i]); | ||
} | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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'); | ||
}); | ||
}); | ||
}); | ||
|
||
|
There was a problem hiding this comment.
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?