-
Notifications
You must be signed in to change notification settings - Fork 1.8k
relatedTarget missing from focus and blur events #855
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
Comments
I don't think it's part of the React Native API so I'm curious what you need it for |
We might be able to work around it. @sidhu663 should have some thoughts. |
We're currently using this for focus management. We keep track of the focusable nodes within a modal and if the relatedTarget on a blur is outside the focusable set, we know that it's a focusout. I don't believe React Native has an onFocusOut since onBlur bubbles so I'm not sure how it could be determined whether the blur will result in a focus loss or not without the related target. Maybe it's possible to use document.activeElement but it seems that the body has focus during the blur phase before the focus on the target happens which we can't capture within a component |
Perhaps you could look into doing this outside of React / React Native? That's how this library juggles some focus related tasks that need to happen out of tree, and it's how PlayStation implemented controls for focus-based UIs with RNW. Also worth noting that OSS focus traps don't rely on |
Thanks for the info. I'll look into working around this today. |
Any follow up? |
We worked around it by using |
Ok |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
When using handlers for
onFocus
andonBlur
therelatedTarget
property is missing fromevent.nativeEvent
If the current behavior is a bug, please provide the steps to reproduce:
Checkout this glitch: https://glitch.com/edit/#!/rnw-relatedtarget-bug
relatedTarget
isundefined
when the event is normalized byreact-native-web
(check the console output)What is the expected behavior?
event.nativeEvent.relatedTarget
would be set for focus events.It looks like this property is also set on some mouse events: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/relatedTarget
Environment (include versions). Did this work in previous versions?
It looks like the issue was introduced with this commit: b4e4bfb#diff-e1a663dbcbd141f6fa72d76ecc2260ac
The text was updated successfully, but these errors were encountered: