Skip to content
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

Synthetic event warning onKeyDown #514

Closed
JemarJones opened this issue May 16, 2017 · 5 comments
Closed

Synthetic event warning onKeyDown #514

JemarJones opened this issue May 16, 2017 · 5 comments

Comments

@JemarJones
Copy link
Contributor

With the latest version of the daterangepicker i get the following warnings logged if i for example click into the start date input, type something and hit cmd + A.

Warning: This synthetic event is reused for performance reasons. If you're seeing this, you're accessing the method `stopPropagation` on a released/nullified synthetic event. This is a no-op function. If you must keep the original synthetic event around, use event.persist(). See https://fb.me/react-event-pooling for more information.

printWarning	@	warning.js?8a56:36
warning	@	warning.js?8a56:60
warn	@	SyntheticEvent.js?2535:265
get	@	SyntheticEvent.js?2535:259
onKeyDown	@	DateInput.js?2f69:265
invokeFunc	@	index.js?f580:160
trailingEdge	@	index.js?f580:207
timerExpired	@	index.js?f580:195
Warning: This synthetic event is reused for performance reasons. If you're seeing this, you're accessing the method `key` on a released/nullified synthetic event. This is a no-op function. If you must keep the original synthetic event around, use event.persist(). See https://fb.me/react-event-pooling for more information.

printWarning	@	warning.js?8a56:36
warning	@	warning.js?8a56:60
warn	@	SyntheticEvent.js?2535:265
get	@	SyntheticEvent.js?2535:259
onKeyDown	@	DateInput.js?2f69:272
invokeFunc	@	index.js?f580:160
trailingEdge	@	index.js?f580:207
timerExpired	@	index.js?f580:195

I notice that you're throttling the onKeyDown event handler, so it may be that the event is nullified by the time the handler is actually called, as described here http://stackoverflow.com/questions/35435074/using-debouncer-with-react-event. This makes sense to me as the warning is being thrown on the trailing edge of the throttle.

@JemarJones
Copy link
Contributor Author

JemarJones commented May 17, 2017

I can confirm that modifying the source and setting the trailing to false does fix the issue. I believe this would result in onKeyDown only being called on the leading edge. Another possible solution would be wrapping the call to the throttled handler and persisting the event.

Either fix would be pretty simple so i could make a PR if someone could confirm which solution seems better.

@basarat
Copy link

basarat commented May 29, 2017

Verified incident report in our code base 🌹:

image

@mikelambert
Copy link
Contributor

I just stumbled on this warning message in my codebase, and tracked it down to react-dates.

Yes, wrapping and persisting the event is fully compatible with existing behavior. But I'd probably prefer the trailing: false solution, since these key events are used for navigation, and it'd be nice to not do an additional navigation when you let go of a key.

I'm not sure if anyone's reading your bug report and offer of help, so just submitting a PR and gathering feedback, is probably the best way to get your question answered. Are you interested in doing that @JemarJones , or should I?

mikelambert added a commit to mikelambert/react-dates that referenced this issue Aug 24, 2017
Fixes react-dates#514 , which happens due to Events being stored to be delivered on the trailing edge of a keyDown. I believe we don't need the trailing edge, and it is better than a persisted Event.
@cecton
Copy link

cecton commented Oct 27, 2017

I'm not 100% sure it is related but I have the problem in 14.0.0 14.1.0 and 13.0.6 by simply pressing SHIFT+TAB to switch to the next field. I have a lot of fields on my page and I want to navigate to the next one.

Nothing special in my code, I just inserted your component today with all the default parameters of the example. I tested on Firefox 56.

"Warning: This synthetic event is reused for performance reasons. If you're seeing this, you're accessing the method stopPropagation on a released/nullified synthetic event. This is a no-op function. If you must keep the original synthetic event around, use event.persist(). See https://fb.me/react-event-pooling for more information." warning.js:33
printWarning warning.js:33
warning warning.js:57
warn SyntheticEvent.js:266
get SyntheticEvent.js:260
onKeyDown DateInput.js:383
invokeFunc debounce.js:95
trailingEdge debounce.js:142
timerExpired debounce.js:130

[edit]: I though it was TAB but it is actually shift+tab so it's probably more SHIFT

@Magellol
Copy link

@cecton Experiencing the same issue. shift+tab to switch from one input to another fields triggers the warning. I'm in chrome 62.

This synthetic event is reused for performance reasons. If you're seeing this, you're accessing the method stopPropagation on a released/nullified synthetic event. This is a no-op function. If you must keep the original synthetic event around, use event.persist(). See https://fb.me/react-event-pooling for more information

mikelambert added a commit to mikelambert/react-dates that referenced this issue Dec 20, 2017
Fixes react-dates#514 , which happens due to Events being stored to be delivered on the trailing edge of a keyDown. I believe we don't need the trailing edge, and it is better than a persisted Event.
erin-doyle pushed a commit that referenced this issue Dec 22, 2017
Fixes #514 , which happens due to Events being stored to be delivered on the trailing edge of a keyDown. I believe we don't need the trailing edge, and it is better than a persisted Event.
devs-cloud pushed a commit to devs-cloud/react-date that referenced this issue Dec 27, 2019
Fixes react-dates/react-dates#514 , which happens due to Events being stored to be delivered on the trailing edge of a keyDown. I believe we don't need the trailing edge, and it is better than a persisted Event.
MarcoAntonioAG pushed a commit to MarcoAntonioAG/React-dates that referenced this issue Mar 31, 2022
Fixes react-dates/react-dates#514 , which happens due to Events being stored to be delivered on the trailing edge of a keyDown. I believe we don't need the trailing edge, and it is better than a persisted Event.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants