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

[Radio] Cannot show "focus" after radio group value changed #38576

Closed
2 tasks done
JakeNg55555 opened this issue Aug 21, 2023 · 3 comments
Closed
2 tasks done

[Radio] Cannot show "focus" after radio group value changed #38576

JakeNg55555 opened this issue Aug 21, 2023 · 3 comments
Labels
component: radio This is the name of the generic UI component, not the React module! status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it

Comments

@JakeNg55555
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Link to live example:
https://codesandbox.io/s/practical-nobel-w2rm4z?file=/Demo.tsx

Steps:

  1. test the result without any value change, the radio can be focus on every 3 seconds separately (including gray circle if the radio wasn't select
  2. refresh the page, change the value (e.g. Other > Male) in first 2 second and leave focus to check the result

Current behavior 😯

The Group Label can highlight 'i.e. Gender'
however, the radios cannot show the "focus" circles

Expected behavior 🤔

expect step 2 should be same as step 1

Context 🔦

in our use case, we want tell the radioGroup to do focus (actually should be the selected one) under some condition, however, it cannot be achieve after any value changed inside the group

Your environment 🌎

you may refer to codesandbox to check the environment, we fork it directly from one of the mui demo page

@JakeNg55555 JakeNg55555 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 21, 2023
@zannager zannager added the component: radio This is the name of the generic UI component, not the React module! label Aug 22, 2023
@mj12albert
Copy link
Member

we want tell the radioGroup to do focus (actually should be the selected one) under some condition

@JakeNg55555 Do you think you could update the sandbox to give some examples of these conditions?
I can see what you are trying to show in the repro with setTimeout, but I'm not sure what we could do without knowing more about your use-case first ~

@mj12albert mj12albert removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 24, 2023
@JakeNg55555
Copy link
Author

we want tell the radioGroup to do focus (actually should be the selected one) under some condition

@JakeNg55555 Do you think you could update the sandbox to give some examples of these conditions? I can see what you are trying to show in the repro with setTimeout, but I'm not sure what we could do without knowing more about your use-case first ~

@mj12albert we have forked another version
https://codesandbox.io/s/ancient-hill-2c7l4c?file=/Demo.tsx

we haven't place all the things in the context, just consider there is a text box and input a human name, if it is empty, gender must select as "Other"
in codesandbox, you can aware there is a grey default focus on "Other" ( this is why we use setTimeout to simulate the expected focus behavior, same as previous sandbox), and we expect have same result for below action:
When we click submit button,
line 26: myRef3.current.focus(); triggered, "Other" is focused actually, but there is no eye-catching change to let our user know it was focused on "Other"

@michaldudak
Copy link
Member

This behavior is consistent with the native radio inputs and is expected.
The grey/blue outline is the focus-visible style. Once you use a mouse to select a radio button, the browser does not apply focus-visible styles, but only the focus styles.
Try using a keyboard (up or down arrow) to select another radio button - the outline would still be applied.

If you wish to style the focus state, you can add your own CSS. For example:

.MuiRadio-root:focus-within {
  /* your styles */
}

@michaldudak michaldudak closed this as not planned Won't fix, can't repro, duplicate, stale Aug 30, 2023
@michaldudak michaldudak added the status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it label Aug 30, 2023
@michaldudak michaldudak removed their assignment Aug 30, 2023
@michaldudak michaldudak changed the title [Radio Group/Radio] cannot show "focus" after radioGrp value changed [Radio] Cannot show "focus" after radio group value changed Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: radio This is the name of the generic UI component, not the React module! status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it
Projects
None yet
Development

No branches or pull requests

4 participants