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

bug(material/radio): Focus styling remains applied after mouseup #25090

Closed
1 task
RobinKamps opened this issue Jun 16, 2022 · 4 comments · Fixed by #25232
Closed
1 task

bug(material/radio): Focus styling remains applied after mouseup #25090

RobinKamps opened this issue Jun 16, 2022 · 4 comments · Fixed by #25232
Assignees
Labels
area: material/radio P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent regression This issue is related to a regression

Comments

@RobinKamps
Copy link

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

sadly, the material radiobutton stays focused after being selected.
This could be intended by the material specs - #14290
But other material components like checkbox or inputs does not have this behavior.
The material specs ( https://material.io/components/selection-controls#radio-buttons ) mention a "Pressed Focus" state - but the animation does show a different behavior after click: https://kstatic.googleusercontent.com/files/bed79fcf6804cded983c22cde6ee42734fce03e47589c4f3d4338405c67cd0b7e28a30c4fbcf9eea0403fb2e8846c4264d432451a31eb7bd364e94d30b1e77d2

perhaps the behavior to keep a "pressed focused" state or to remove focus (and defocus just like all other elements/checkboxes) could be made optional.

Reproduction

Steps to reproduce:
head to https://material.angular.io/components/radio/examples and click a radio button

Expected Behavior

the focus / animation / big transparent ripple circle should disappear

Actual Behavior

the focus / animation / big transparent ripple circle does not disappear

Environment

  • Angular:
  • CDK/Material:
  • Browser(s):
  • Operating System (e.g. Windows, macOS, Ubuntu):
@RobinKamps RobinKamps added the needs triage This issue needs to be triaged by the team label Jun 16, 2022
@amysorto
Copy link
Contributor

Seems like the focus styling being persistent starts in v11 since it doesn't happen on the docs site for v10: https://v10.material.angular.io/components/radio/examples.

@amysorto amysorto added P4 A relatively minor issue that is not relevant to core functions area: material/radio regression This issue is related to a regression P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed needs triage This issue needs to be triaged by the team P4 A relatively minor issue that is not relevant to core functions labels Jun 17, 2022
@amysorto amysorto changed the title material radio button stays focused bug(material/radio): Focus styling remains applied after mouseup Jun 17, 2022
@crisbeto crisbeto self-assigned this Jul 4, 2022
@crisbeto
Copy link
Member

crisbeto commented Jul 4, 2022

Related issue that'll be resolved when this one is (with some small changes in the checkbox): #18912.

@RobinKamps
Copy link
Author

Thank you very much for pointing to the related issue.
Quick fix if needed:

.mat-radio-persistent-ripple {
  .mat-radio-button.cdk-focused:not(:hover) & {
    opacity: 0 !important;
  }
  .mat-radio-button.cdk-focused:hover & {
    opacity: 0.06 !important;
  }
}

@crisbeto crisbeto added the has pr label Jul 6, 2022
crisbeto added a commit to crisbeto/material2 that referenced this issue Jul 6, 2022
In most cases focus moves during the `mousedown` event so all of our detection uses `mousedown` events to track it. It breaks down for the common use case where a `label` is connected to an `input`, because there focus moves on the `click` event instead. This has been a long-standing issue with the `FocusMonitor` that has caused problems with `mat-checkbox`, `mat-radio-button` and `mat-slide-toggle`.

These changes add special handling for the `input` + `label` case that checks if the previous mouse interaction was with a label belonging to the current `input` receiving focus.

Fixes angular#25090.
crisbeto added a commit that referenced this issue Jul 11, 2022
In most cases focus moves during the `mousedown` event so all of our detection uses `mousedown` events to track it. It breaks down for the common use case where a `label` is connected to an `input`, because there focus moves on the `click` event instead. This has been a long-standing issue with the `FocusMonitor` that has caused problems with `mat-checkbox`, `mat-radio-button` and `mat-slide-toggle`.

These changes add special handling for the `input` + `label` case that checks if the previous mouse interaction was with a label belonging to the current `input` receiving focus.

Fixes #25090.
crisbeto added a commit that referenced this issue Jul 11, 2022
In most cases focus moves during the `mousedown` event so all of our detection uses `mousedown` events to track it. It breaks down for the common use case where a `label` is connected to an `input`, because there focus moves on the `click` event instead. This has been a long-standing issue with the `FocusMonitor` that has caused problems with `mat-checkbox`, `mat-radio-button` and `mat-slide-toggle`.

These changes add special handling for the `input` + `label` case that checks if the previous mouse interaction was with a label belonging to the current `input` receiving focus.

Fixes #25090.

(cherry picked from commit 089eb6f)
crisbeto added a commit that referenced this issue Jul 11, 2022
In most cases focus moves during the `mousedown` event so all of our detection uses `mousedown` events to track it. It breaks down for the common use case where a `label` is connected to an `input`, because there focus moves on the `click` event instead. This has been a long-standing issue with the `FocusMonitor` that has caused problems with `mat-checkbox`, `mat-radio-button` and `mat-slide-toggle`.

These changes add special handling for the `input` + `label` case that checks if the previous mouse interaction was with a label belonging to the current `input` receiving focus.

Fixes #25090.

(cherry picked from commit 089eb6f)
@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 Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/radio P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent regression This issue is related to a regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants