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 a useFocusReturn hook #27572
Add a useFocusReturn hook #27572
Conversation
Size Change: -256 B (0%) Total Size: 1.21 MB
ℹ️ View Unchanged
|
9e2995e
to
f6ad5ec
Compare
a99c569
to
7e79b57
Compare
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.
The issue I raised in #27572 (comment) is fixed now so ✅
I see some test failures in e2e tests, any idea what could happen?
@gziolo Yes, my fix for the previous issue introduced a new one in the inserter :P now they're both fixed. |
Now I see a failing unit test but it's an issue with the test as far as I can tell. |
73291fe
to
a6b3244
Compare
yes, the event was not firing properly in the test, something related to the test library. |
|
||
// Unmounting the reference | ||
if ( ! newNode && focusedBeforeMount.current ) { | ||
if ( newNode?.ownerDocument ) { |
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.
How can newNode.ownerDocument
be defined if previously there's a check for ! newNode
?
I think there's a problem with the new implementation. The hooks (previously HoC) promises to return focus if a component unmounts, but it seems focus will now also be returned if the node change and focus is outside the component. |
It's intended, the focus must be returned not when the focus unmounts but when the node changes (the previous node unmounts if you want) |
This implementation is a bit different/simpler compared to the previous withFocusReturn HoC. I'd like to understand where it fails in order to come with the best strategy forward (re add the context or figure out something else)