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
Modal doesn't trap focus #770
Comments
Thanks for reporting! |
I tried fix this bug. seems need change like 3 files. Drawer passRefModal, Modal pass modalRef and useFocusReturn pass the ref to trigger last active focus. so I think use setTimeout on 1 line code it's not gonna hurt |
Fixed in 5.1.4, Modal and Drawer components now support |
Hey @rtivital, would be awesome if withFocusReturn were dynamic. My use case is under certain circumstances I do want the focus to return when I close the modal, but other time I don't. In my modal there is an action that closes the modal and renders an input the main part of the app. This input should be focused after closing the modal. However, when the modal is closed without taking this action the focus should return to where it was before. Could |
I'll make it dynamic without function in next patch |
Hi. I stumbled upon a scenario when a modal can't trap focus. It goes like this:
As a result, the modal is opened but it has no focus and doesn't close by pressing ESC.
The reason it happens is that the drawer is animated. If I wait for 300ms before opening the modal, everything works as expected.
I don't know what the fix here would be. Maybe I could tell the drawer to pass focus to the modal via ref in some callback?
The text was updated successfully, but these errors were encountered: