-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Select] - First options receives .Mui-focusVisible always #23747
Comments
@orest22 Interesting, it's because of this line: You can reproduce using the native CSS feature: https://codesandbox.io/s/material-ui-issue-forked-mk5wi?file=/src/Demo.js. I suspect a bug in Chrome. |
Thanks for the detailed report. Definitely needs some investigation how this happens. Only then can we know whether this is a chrome bug or Material-UI bug. |
@eps1lon could it be related to a question you have asked here https://bugs.chromium.org/p/chromium/issues/detail?id=1127875 ? |
This bug happens for me on a clean install on latest MUI version, both on chrome and firefox. Here is a sandbox. |
This is still a problem btw. Anyway to fix this? |
I'm currently experiencing this on Chrome using MenuUnstyled and MenuItemUnstyled. |
Same here. I have a search input in my |
I also encountered the same event. |
Well this issue is not related to the MUI.
@orest22 i think you can reproduce the same thing for the menu with two possible implementations of Anchor that opens the menu:
Same behavior with vanilla js in this example @oliviertassinari possible fix is to remove this line useIsFocusVisible the focus-visible should be applied only if the user uses keyboard no need to check focus-visible matches. |
Has there been any progress for this? |
I am also experiencing same!! |
This issue is still there - I understand that according to spec, the first item gets the focus automatically... but so far MUI was good at applying the focusVisible class on focused elements only when user used keyboard. So the fix is to remove focusVisible class if the user interacted using mouse. Interestingly this issue is not there if user navigated from another screen in single page app. |
This issue can be tackled by using a MenuItem Component (as 1st Option) and setting it's display property to "none". |
still the issue, but this workaround helped
|
Today I leaned about this option: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#focusvisible / https://html.spec.whatwg.org/multipage/interaction.html#focus-management-apis: .focus({ focusVisible: false }); that we could maybe used to solve this issue and dodge w3c/csswg-drafts#5885. Now, I imagine that we can't systematically use this, first the |
IMO the path forward for focus visible handling in Material UI should rely on |
Agree with @DiegoAndai. If possible, we should try to simplify and move work to CSS. I don't have the right context to know if |
Current Behavior 😯
There is some issue with
:focus-visible
for Select. For the first time when there is no value selected.Mui-focusVisible
class is getting applied to the first item in a list. This is not the case for the Menu component though. Also, this happens only in Chrome.Expected Behavior 🤔
Same behaviour as the Menu component has.
Steps to Reproduce 🕹
Two components side by side:https://codesandbox.io/s/material-ui-issue-forked-udm04?file=/src/Demo.js
Steps:
Case 1:
focusVisible
class was addedCase 2:
Context 🔦
Want have focus applied on Select only when it was focused with a keyboard. The options should also stay without focus if the keyboard wasn't used
Your Environment 🌎
The text was updated successfully, but these errors were encountered: