From ed29976896beaef24b1114817eaebd9a6fc6287e Mon Sep 17 00:00:00 2001 From: farfromrefuge Date: Mon, 14 Feb 2022 17:34:25 +0100 Subject: [PATCH] fix(android): disable animations for all in between fragments during a transition (#9772) This prevent the wrong `transitionEnd` to be called last and thus the wrong `setCurrent` to be called on a released entry --- packages/core/ui/frame/index.android.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/core/ui/frame/index.android.ts b/packages/core/ui/frame/index.android.ts index 177d2b4c5..2e079b91d 100644 --- a/packages/core/ui/frame/index.android.ts +++ b/packages/core/ui/frame/index.android.ts @@ -426,7 +426,14 @@ export class Frame extends FrameBase { //TODO: Check whether or not this is still necessary. For Modal views? //transaction.setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN); } - + if (clearHistory || isReplace) { + // we need to ensure we dont listen for animations of + // in between fragments or they could break our transition end handling + // and set the wrong current entry + for (let index = 0; index < this.backStack.length; index++) { + _clearEntry(this.backStack[index]); + } + } transaction.replace(this.containerViewId, newFragment, newFragmentTag); transaction.commitAllowingStateLoss(); } @@ -448,7 +455,14 @@ export class Frame extends FrameBase { } _reverseTransitions(backstackEntry, this._currentEntry); - + const currentIndex = this.backStack.length; + const goBackToIndex = this.backStack.indexOf(backstackEntry); + for (let index = goBackToIndex + 1; index < currentIndex; index++) { + // we need to ensure we dont listen for animations of + // in between fragments or they could break our transition end handling + // and set the wrong current entry + _clearEntry(this.backStack[index]); + } transaction.replace(this.containerViewId, backstackEntry.fragment, backstackEntry.fragmentTag); transaction.commitAllowingStateLoss();