-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Disabling a button while clicking it leads to invalid Focus-Outline shown later on #1164
Comments
I think this is related, #1157
|
After investigating, it would appear that we are running into this Issue facebook/react#9142 As a workaround, you will need to first move focus to the new element. THEN disable the button via state. Focus and blur will then happen before the update instead of during it. |
well in my case that might be a possible work-around but in other scenarios this will not work because one probably does not know where the focus should go next and it might turn out hard to not violate accessibility rules because you need to shift the focus to the appropriate previous focus element (not sure about the rules there). In general this means that one has to guard all elements in a codebase who could potentially get disabled while holding the input focus. |
I mean, that's no different than you would have to do no matter what. In the case of something such as a pagination component, buttons - [prev, 1, 2, 3, ..., next], if you're on prev and you get down to page one, prev is typically disabled. The component knows this and will take care of moving focus to an appropriate element within itself if it can. |
Thanks did not know about this focus-manager thing! |
🐛 Bug Report
If you disable a button when clicking the very same button leads to an invalid focus-outline if you afterwards move focus using the the keyboard leading to an UI like this:
🤔 Expected Behavior
No focus outline on the disabled button
😯 Current Behavior
2 Focus-Outlines appear on 2 different controls
💁 Possible Solution
🔦 Context
I tried to implement a wizard dialog and ran into this
💻 Code Sample
Add this snippet to the ButtonGroup.stories.tsx
To reproduce:
🌍 Your Environment
🧢 Your Company/Team
🕷 Tracking Issue (optional)
The text was updated successfully, but these errors were encountered: