ReactCSSTransitionGroup leaves DOM nodes with both `leave` and `enter` classes
After sequence of fast changes (add/delete operations) nodes under ReactCSSTransitionGroup are left stuck with classes example-leave example-enter-active example-leave-active. Further state modifications do not change rendered DOM tree. Console has multiple warnings
transition(): tried to perform an animation without an animationend or transitionend event after timeout (5000ms). You should either disable this transition in JS or add a CSS animation/transition.
Test page: http://jsbin.com/kasurusa/2
- Place cursor in input field
- Type l then type Backspace very fast
- Repeat step 2 few times
Easily reproduces in IE10, but could be also reproduced in Chrome 35.
Code in ReactCSSTransitionGroupChild sometimes is executed in wrong sequence.
It assumes that independent asynchronous callbacks flushClassNameQueue and endListener are always executed in proper sequence:
-
2.1
CSSCore.addClass(this.getDOMNode(), 'example-leave-active') -
3.1
CSSCore.removeClass(node, 'example-leave'); CSSCore.removeClass(node, 'example-leave-active');
What sometimes happens:
-
transition('leave')1.1
CSSCore.addClass(node, 'example-leave')- initiates CSS transition -
endListener- transition is finished2.1
CSSCore.removeClass(node, 'example-leave'); CSSCore.removeClass(node, 'example-leave-active'); -
flushClassNameQueue- only thensetTimeouttimer fired3.1
CSSCore.addClass(this.getDOMNode(), 'example-leave-active')
@chenglou any updates on this?
Encountered the same issue =\ @victor-homyakov You found any workaround?
Manual patching of those places where the classes are added/removed helped to some extent, but not completely. The algorithm of the addon should be rewritten to avoid using both event observers and timeouts simultaneously, but this requires some amount of time. Taking in account other issues easier was not to use this addon at all.
I have also encountered this issue with multiple DOM objects (20+) listening after a fast sequence of changes.
I am seeing a similar issue as well. Sometimes, React does not always eliminate the enter and enter-active classes. In this case, transitioning to a different element will result in the former element remaining in the DOM.
+1 Just have bumped into the same issue.
+1 Any chances that it will be fixed?
I was able to solve it by tweaking the order of state variables applied to the component's state. E.g.:
this.setState(updateAB) --> this.setState(updateA); this.setState(updateB);
I've been running into this issue too. Usually with enter and enter-active not being removed as @lsvx mentioned.
I just played around with Khan Academy's TimeoutTransitionGroup. I still see animation glitches occur, but the components do get correctly removed, so at least it prevents my app from getting stuck in a broken state.
I have a similar issue, it happens when changing the cssClass property of an element during his transition.
+1 getting rid of a nice animation to fix this bug in our code :-/
I tweaked Khan Academy's TimeoutTransitionGroup to avoid another problem. Maybe it also fixes this problem, so give it a try!
Here's my version:
https://gist.github.com/gaearon/f18a33e3bd58275762f4
+1 breaks all my things. :/
Just saw the same issue. React (with addons) v0.12.2.
I have a form that adds things and a table that should list the last 5 things (with animation). If I add many things quickly it will sometimes list more than 5, with the foo-enter and foo-enter-active classes remaining on the surplus elements.
+1 I have this sometimes. (take a look at https://github.com/ccoenraets/pageslider-react it might solve some issues)
Same issue here, it does seem to be related to changing the classes on an item that is transitioning. Simply adding another element within the transitioning item and changing classes on that fixes the issue.
+1
+1 causing issues on iOS for me.