-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Components: Trigger focus return by tracking focus events #2321
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2321 +/- ##
==========================================
+ Coverage 25.34% 25.42% +0.07%
==========================================
Files 152 152
Lines 4754 4760 +6
Branches 807 808 +1
==========================================
+ Hits 1205 1210 +5
- Misses 2996 2997 +1
Partials 553 553
Continue to review full report at Codecov.
|
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.
Tested on the Inserter, works great. Thanks!
Partially addresses #2306
This pull request seeks to refactor the
withFocusReturn
higher-order component to track an instance property reflecting whether the rendered element currently has focus. This proves to be more reliable when the disposable component is portaled to another location in the DOM (#2306), since the previouselement.contains
test will not match said content. Instead, the implementation here leverages event bubbling (and event bubbling of portaled content) to track at all times whether the wrapped component has focus. Then, the focus return condition is simply a matter of: Is the component unmounting while it has focus?Testing instructions:
Verify that focus is returned to initial active element after dismissing a
withFocusReturn
component: