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

Radiobutton doesn't focus when selecting the associated label #14753

Closed
juristr opened this issue Jan 8, 2019 · 6 comments · Fixed by #14967
Closed

Radiobutton doesn't focus when selecting the associated label #14753

juristr opened this issue Jan 8, 2019 · 6 comments · Fixed by #14967
Assignees
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@juristr
Copy link

juristr commented Jan 8, 2019

What is the expected behavior?

Clicking the radiobutton in a radio button list should select the radio button accordingly.

What is the current behavior?

Clicking the radiobutton in a radio button list does activate the clicked radio button in case when I select the label text. The ripple effect of the click however triggers properly

material-radiobuttonlist-bug

What are the steps to reproduce?

Can be reproduced directly on the material docs site: https://material.angular.io/components/radio/overview

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

latest of both, tried in the docs site.

Is there anything else we should know?

Happy to provide a PR with some guidance where the issue could be.

@Suresh918
Copy link
Contributor

Suresh918 commented Jan 9, 2019

Not able to reproduce. It's working as expected when I checked now at https://material.angular.io/components/radio/overview

@andrewseguin
Copy link
Contributor

Seems to be working on our end as well. Not sure what caused the issue but if you can reproduce, feel free to re-open

@juristr
Copy link
Author

juristr commented Jan 12, 2019

@andrewseguin 🤔 hmm...I still reproduce it. You have to select the label and click on that label, not the radio button itself. Reproduced in Chrome and on MacOS.

Here's a short video where I reproduce it: https://youtu.be/oR-LRzvlfRA

Update: this apparently also happens if you select any other text on that same page, not only the radio label text 🤔

@andrewseguin
Copy link
Contributor

Thanks for the video, that helps a lot. Definitely looks like a bug, albeit a bit low priority but something we ought to get fixed.

@andrewseguin andrewseguin reopened this Jan 16, 2019
@swseverance
Copy link
Contributor

I'm able to reproduce in Chrome, but not in Safari on MacOS. The issue appears to be that although a click event does get dispatched to the label element, a generated click event does not appear to be dispatched to the input element. I'm unable to explain why that is.

However, the following changes seem to resolve the issue:

radio.html

<label [attr.for]="inputId" class="mat-radio-label" #label (click)="_onLabelClick()">

radio.ts

_onLabelClick() {
  this._inputElement.nativeElement.click();
}

I can submit a PR with these changes but as of now I'm unable to provide an accompanying unit test that replicates the behavior we're seeing.

@andrewseguin andrewseguin added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Jan 23, 2019
@crisbeto crisbeto self-assigned this Jan 26, 2019
crisbeto added a commit to crisbeto/material2 that referenced this issue Jan 26, 2019
Fixes not being able to select a radio button by clicking on it, if part of the text of the label is marked.

Fixes angular#14753.
mmalerba pushed a commit that referenced this issue Feb 1, 2019
Fixes not being able to select a radio button by clicking on it, if part of the text of the label is marked.

Fixes #14753.
mmalerba pushed a commit that referenced this issue Feb 4, 2019
Fixes not being able to select a radio button by clicking on it, if part of the text of the label is marked.

Fixes #14753.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants