-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[a11y]: Modal: doesn't return focus properly on dismissal #13680
Comments
Thanks for reporting this. I can reproduce it in the storybook by focusing the "Launch modal" button, pressing enter to open the modal, and pressing esc to close the modal. Focus is not returned to the button |
How this was originally outlined in parent #12727
|
I'm not sure we can handle this on our end, since const closeButton = useRef();
<Button ref={closeButton} onClick={() => setOpen(true)}>
Launch composed modal
</Button>
<ComposedModal
open={open}
onClose={() => {
setOpen(false);
setTimeout(() => {
closeButton.current.focus();
});
}}> Any other ideas? |
Put up #14355 that adds in a new prop |
Package
@carbon/react
Browser
Chrome
Operating System
MacOS
Package version
v1.25.0
React version
v16.12.0
Automated testing tool and ruleset
manual testing
Assistive technology
No response
Description
When launching a Modal from a button, focus goes inside the Modal, as it should. When dismissing the Modal, focus should return to the button where it was launched from.
This issue was mentioned in #12727, but i thought it was worth splitting out separately.
https://www.w3.org/WAI/WCAG21/Understanding/focus-order
Optimally, we'd automatically save off focus on launch and reset it on dismissal. Alternatively, having a prop for a selector to return focus too would also be an option.
WCAG 2.1 Violation
WCAG 2.1, focus order
Reproduction/example
any implementation of Modal from a button
Steps to reproduce
Launch a modal from a button. Dismiss modal. Note focus does not return to previous location. Focus is on the main
body
node after Modal dismissal.Code of Conduct
The text was updated successfully, but these errors were encountered: