-
-
Notifications
You must be signed in to change notification settings - Fork 445
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
Add environment prop #365
Add environment prop #365
Conversation
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12733599 | ||
canUseActiveElement = false; | ||
|
||
function determineCanUseActiveElement(environment) { |
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.
Wrapping this into a function that runs only once (since initially canUseActiveElement
is undefined
) to be able to use the environment
from the props instead of assuming window
.
@@ -1,6 +1,3 @@ | |||
/** | |||
* @jest-environment node |
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.
Allowed this tests to run on jsdom
so that window
can be used. All tests keep working.
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.
Did accessing window crash the test? Or how did you notice this?
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.
Yes, it was because of having the tests failing on CI: https://travis-ci.org/github/reactjs/react-tabs/builds/753987091
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.
I think we have to make sure that window is not required, so that tests still work without window and more important possible server-side rendering does not crash, because window is not available there.
So before accessing window
there always needs to be a typeof window !== 'undefined'
.
By quickly thinking about it I would try to change the code so that there is no default value and the new determineCanUseActiveElement
should fallback to window
if no environment
given and also handle the case where environment
not set and window
also not available.
@danez Thanks for reviewing! I added the checks and reverted the Node test to make it work as before. |
🎉 This PR is included in version 3.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I've ran into a use case where the focus between tabs wasn't properly handled while navigating using the arrow keys due to having
react-tabs
rendered on aniframe
.Inspired by
downshift
, this PR adds anenvironment
prop to allow users to specify a differentwindow
if they need to.