Skip to content

Commit f88fba0

Browse files
matskoMatias Niemelä
authored andcommitted
fix(animations): avoid animation insertions during router back/refresh (#21977)
Closes #19712 PR Close #21977
1 parent 32105c8 commit f88fba0

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

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

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

0 commit comments

Comments
 (0)