-
Notifications
You must be signed in to change notification settings - Fork 808
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
[fixed] Focus trap when reentering document (#742) #791
Conversation
Legit. @holloway Have you found what broke the tests? |
@holloway Ping me if you need anything...not sure if I'm receiving the notifications from this repo or if I'm skipping without looking... :) |
@diasbruno Yeah the test bug was caused by making those trap elements in So that's passing now. |
src/helpers/bodyTrap.js
Outdated
import portalOpenInstances from "./portalOpenInstances"; | ||
// Body focus trap see Issue #742 | ||
|
||
let before, after, instances; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ýou can initialize instances
with an empty array.
Thanks, @holloway. I merged your PR and will run a few tests on it. |
@holloway When the page gets the focus back - testing on firefox -, I'm seen that I need "a extra tab" because |
@diasbruno hmm... I can't reproduce that behaviour in Firefox v71 (Linux), and I haven't heard of Firefox overriding JS-controlled focus in that way. What are the exact reproduction steps? For me, in Firefox and in Chrome, it restores focus to the button that it opened from. But you're seeing a change in behaviour compared to the ReactCommunity Codepen examples? fyi I have tested focus management by running this to log the current element every second,
And then interacting with the page to see how focus is moved around, and that part (when the page gets focus back) seems to behave as it was before this PR. |
Thats look correct. Maybe this happens when I click on the browser's console and type Steps
|
Firefox 71 here. |
Ah then yes that might move focus to There's a legitimate question about whether focusing I guess the idea of using a |
LGTM. When we get more info about this, we can do something about this. |
@diasbruno fyi I'm told that the extra tab in Firefox is expected behaviour that we wouldn't want to interfere with when a modal is open. FF users are in the habit of hitting tab twice, so this PRs' approach is still appropriate. |
bump! 😄 |
🤦♂️ Thanks, @holloway. |
Release |
No probs, thanks @diasbruno ! |
* [added] Focus trap when reentering document (reactjs#742)
Fixes #742
Changes proposed:
Upgrade Path (for changed or removed APIs):
Acceptance Checklist:
CONTRIBUTING.md
.[ ] Documentation (README.md) and examples have been updated as needed.N/A I think[ ] If the commit message has [changed] or [removed], there is an upgrade path above.N/A I think