-
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
Don't cache purged nodes that are focused on unmount #3144
Conversation
Why does adding a transaction prevent the blur event from firing? |
From
It's not that it prevents the blur event from firing -- that's a bad description on my part -- it just suspends React's listening to it. I'll fix that comment, my bad. |
Not really familiar with this part of React, but it seems to me that it would make more sense to just use cc @zpao ... ? |
@syranide, that was my impulse too; I went with the full-blown transaction because it didn't look like The "blur-on-destroy" thing feels like a special case, though, so if you all think it'd be all right, I'm happy to swap in var previouslyEnabled = ReactBrowserEventEmitter.isEnabled();
ReactBrowserEventEmitter.setEnabled(false);
ReactMount.unmountComponentFromNode(component, container);
ReactBrowserEventEmitter.setEnabled(previouslyEnabled); which also seems to work. I'd also love to get a test added for this, but I couldn't see a clean way to get at |
Fixes #2988. Unmounting was causing the blur event to fire, which was in turn causing the blurred node to be added to the ReactMount.nodecache.
Just keeping this PR up-to-date with the latest changes. It looks like unmounting nodes are still being cached on blur: And fixed with the changes proposed: |
I guess this is related to #3790. I'm not in love with this PR because it feels like a bit of a monkey patch to me instead of fixing the true issue that unmounted components can receive events. |
That's fair. On the other hand it feels like a tradeoff between fighting the browser and ignoring what the browser is trying to tell a component while it's unmounting. In this case, the blur event is expected to fire with the // ReactMount.js#331-333
while (container.lastChild) {
container.removeChild(container.lastChild);
} is removing (in the test case) a I'll keep looking for a better way to prevent React from hitting the unmounting node with the event. I know you all are busy, and I don't mean to bug you with monkey patches. :) |
Is this fixed now? I know we tried to avoid firing events on unmounted components. Regardless we need the full fix. |
#4983 should fix the rest. |
Fixes #2988.
Unmounting was causing the blur event to fire, which was in turn causing the blurred node to be added to ReactMount.nodeCache.