-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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 onChange events not bubbling up on unmount #13459
Comments
Events fired in an order. Although it is just a recommendation, click event should be fired before change event. I wrote your sample once again as vanilla. Try this https://codesandbox.io/s/qrp55omvj on Safari and Chrome and Firefox. My current browser Safari on MAC fires change and click but Chrome fires only click for the dynamically generated checkboxes. |
I think the unexpected behavior and the difference to native elements is caused by the fact that React listens on One thing you can try to work around this by attaching native event listeners for the |
Thanks for the feedback! It sounds like my best bet at the moment is to await the outcome of #10830. If I remove the |
You have created |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution. |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you! |
Do you want to request a feature or report a bug?
I'm reporting a bug.
What is the current behavior?
When attaching an
onChange
handler to a JSX element, if calling this handler leads to the element being unmounted, then theonChange
event never bubbles up in the DOM. This means you can't listen to it on thedocument
, or basically on anything else than the element itself.If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
Example code here: https://codesandbox.io/s/qkr8j85z8j
Try it out here: https://qkr8j85z8j.codesandbox.io
Open the console and click around a bit. You will notice that the single checkbox that never changes it's position triggers both
onClick
andonChange
listeners whereas the other checkboxes that get moved between lists only triggeronClick
events.What is the expected behavior?
I would expect the
onChange
event to be handled in the same way as theonClick
event.Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
Tested under these conditions:
Behaviour has not changed between versions.
The text was updated successfully, but these errors were encountered: