-
Notifications
You must be signed in to change notification settings - Fork 47k
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
react-dom: Ability to access window.event in development #11687
Labels
Comments
Can we just store |
I think that would work — want me to send a pull request?
Sent via Superhuman ( https://sprh.mn/[email protected] )
…On Tue, Nov 28, 2017 at 12:39 PM, Dan Abramov < ***@***.*** > wrote:
Can we just store window.event and immediately set it back when we're
inside our event?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub (
#11687 (comment) ) ,
or mute the thread (
https://github.com/notifications/unsubscribe-auth/AAFwQLyv6GQB91guBhB67rcQ9cu6_Mpoks5s7G9lgaJpZM4Qt3tl
).
|
Yeah if you'd like. |
It's here: #11696 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Imported from #10474 (comment) at request of @gaearon
Do you want to request a feature or report a bug? Bug
What is the current behavior?
In development mode React uses
invokeGuardedCallback
to be able to catch errors without interrupting the normal "break on uncaught exceptions" feature of devtools.In the current implementation of
invokeGuardedCallback
an event is created and dispatched, which allows for error handling without atry{ } catch
block.Unfortunately it has the side effect of overriding
window.event
, and so you are unable to accesswindow.event
within guarded callbacks when running React in development mode. In production mode it works fine.We would like to access window.event at Superhuman to be able to detect where DOM focus is from the user's point of view. Usually this is document.activeElement, but in a few cases (like during a blur event, or when clicking between two iframes) the focus will end up in a different place.
This works fine in production, and we currently work around this in development mode by overriding
ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactDOMEventListener.handleTopLevel
and maintiaining a reference to the event. In production mode we just use window.event.If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template for React 16: https://jsfiddle.net/Luktwrdm/, template for React 15: https://jsfiddle.net/hmbg7e9w/).
in development: https://jsfiddle.net/n782L2qg/, in production: https://jsfiddle.net/kqt2o7pr/. In both cases I would expect the alert to say
window.event.type: click
, but in development it sayswindow.event.type: react-invokeguardedcallback
What is the expected behavior?
I would like a way to access window.event in development. I'm happy for this to be somewhat obscure, but ideally I would not have to use the secret internals to make this work.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? Development 0.15 and 0.16 at least. probably before.
The text was updated successfully, but these errors were encountered: