Skip to content

Commit 641cc49

Browse files
matskoMatias Niemelä
authored and
Matias Niemelä
committed
fix(animations): avoid animation insertions during router back/refresh (#21977)
Closes #19712 PR Close #21977
1 parent a846abb commit 641cc49

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/animations/browser/src/render/transition_animation_engine.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,16 @@ export class TransitionAnimationEngine {
665665
// code does not contain any animation code in it, but it is
666666
// just being called so that the node is marked as being inserted
667667
if (namespaceId) {
668-
this._fetchNamespace(namespaceId).insertNode(element, parent);
668+
const ns = this._fetchNamespace(namespaceId);
669+
// This if-statement is a workaround for router issue #21947.
670+
// The router sometimes hits a race condition where while a route
671+
// is being instantiated a new navigation arrives, triggering leave
672+
// animation of DOM that has not been fully initialized, until this
673+
// is resolved, we need to handle the scenario when DOM is not in a
674+
// consistent state during the animation.
675+
if (ns) {
676+
ns.insertNode(element, parent);
677+
}
669678
}
670679

671680
// only *directives and host elements are inserted before

0 commit comments

Comments
 (0)