You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
When clicking on a button document.activeElement fails in some browsers #389
While this is not a react-modal bug, I thought to report it to share the issue. It's more about different implementations of document.activeElement across browsers/platforms related to buttons.
Everything works as expected when activating a button using the keyboard. However, when clicking with the mouse/trackpad on a button, some browsers return the <body> as document.activeElement.
While it's not a bug and keyboard accessibility is safe, it would be great try to find a way to have the full functionality working also when using a pointing device.
Thanks, @afercia, great report. Maybe it has something to do with how the focusManager works. It's tries to stack all previous focused/active elements (in case one modal is opened from inside other modal), and focus them back when a modal is closed.
So, if a click does not set the element as document.activeElement, there is the problem.
One way to fix this (if it's the correct behavior) would be to use the focusManager to inject the element onto the stack of previous active elements. This way it will give/return the focus to it.
One way to fix this (if it's the correct behavior)
I think it's the best default. In some, rare, cases maybe it would be great to have a built-in way to override the default though and pass a reference to another element to move focus back to. I guess this is a separate issue :)
Activity
diasbruno commentedon Jun 8, 2017
Thanks, @afercia, great report. Maybe it has something to do with how the
focusManagerworks. It's tries to stack all previous focused/active elements (in case one modal is opened from inside other modal), and focus them back when a modal is closed.So, if a click does not set the element as
document.activeElement, there is the problem.One way to fix this (if it's the correct behavior) would be to use the
focusManagerto inject the element onto the stack of previous active elements. This way it will give/return the focus to it.Reference: react-modal#focusManager.js
afercia commentedon Jun 9, 2017
@diasbruno thanks
I think it's the best default. In some, rare, cases maybe it would be great to have a built-in way to override the default though and pass a reference to another element to move focus back to. I guess this is a separate issue :)