From e43c7546bd6e5615e4be105c6c463735f0de912d Mon Sep 17 00:00:00 2001 From: Vasil Chimev Date: Wed, 14 Mar 2018 19:56:15 +0200 Subject: [PATCH] fix-next(frame): remove current entry fragment on reset root view (#5533) * chore(e2e): add @types as devDependencies Update `tsconfig.json` file. * fix-next(frame): remove current entry fragment on reset root view * refactor(e2e): undo skip tab root tests * refactor(frame): extract disposeCurrentFragment() method Extract the common logic from _onRootViewReset() and onUnloaded() methods to avoid code duplication. --- .../tab-root-modal-frame.e2e-spec.ts | 2 +- .../tab-root-modal-page.e2e-spec.ts | 2 +- .../tab-root-modal-tab.e2e-spec.ts | 2 +- e2e/modal-navigation/package.json | 5 ++++- e2e/modal-navigation/tsconfig.json | 4 ++-- tns-core-modules/ui/frame/frame.android.ts | 13 ++++++++++--- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/e2e/modal-navigation/e2e/e2e-spec-tab-root/tab-root-modal-frame.e2e-spec.ts b/e2e/modal-navigation/e2e/e2e-spec-tab-root/tab-root-modal-frame.e2e-spec.ts index 9caf7eaf8..8c226bf98 100644 --- a/e2e/modal-navigation/e2e/e2e-spec-tab-root/tab-root-modal-frame.e2e-spec.ts +++ b/e2e/modal-navigation/e2e/e2e-spec-tab-root/tab-root-modal-frame.e2e-spec.ts @@ -6,7 +6,7 @@ import { modalFrameBackground, testNestedModalPageBackground } from "../shared.e2e-spec" -describe.skip("tab root modal frame background scenarios", () => { +describe("tab root modal frame background scenarios", () => { let driver: AppiumDriver; let screen: Screen; diff --git a/e2e/modal-navigation/e2e/e2e-spec-tab-root/tab-root-modal-page.e2e-spec.ts b/e2e/modal-navigation/e2e/e2e-spec-tab-root/tab-root-modal-page.e2e-spec.ts index 55c9d83a7..48343881b 100644 --- a/e2e/modal-navigation/e2e/e2e-spec-tab-root/tab-root-modal-page.e2e-spec.ts +++ b/e2e/modal-navigation/e2e/e2e-spec-tab-root/tab-root-modal-page.e2e-spec.ts @@ -6,7 +6,7 @@ import { modalPageBackground, testNestedModalPageBackground } from "../shared.e2e-spec" -describe.skip("tab root modal page background scenarios", () => { +describe("tab root modal page background scenarios", () => { let driver: AppiumDriver; let screen: Screen; diff --git a/e2e/modal-navigation/e2e/e2e-spec-tab-root/tab-root-modal-tab.e2e-spec.ts b/e2e/modal-navigation/e2e/e2e-spec-tab-root/tab-root-modal-tab.e2e-spec.ts index 86daa4f7a..7e92c5e13 100644 --- a/e2e/modal-navigation/e2e/e2e-spec-tab-root/tab-root-modal-tab.e2e-spec.ts +++ b/e2e/modal-navigation/e2e/e2e-spec-tab-root/tab-root-modal-tab.e2e-spec.ts @@ -8,7 +8,7 @@ import { modalFrameBackground, testSecondItemBackground } from "../shared.e2e-spec" -describe.skip("tab root modal tab view background scenarios", () => { +describe("tab root modal tab view background scenarios", () => { let driver: AppiumDriver; let screen: Screen; diff --git a/e2e/modal-navigation/package.json b/e2e/modal-navigation/package.json index 9d7333318..b2eed4ed4 100644 --- a/e2e/modal-navigation/package.json +++ b/e2e/modal-navigation/package.json @@ -35,7 +35,10 @@ "uglifyjs-webpack-plugin": "~1.1.6", "webpack": "~3.10.0", "webpack-bundle-analyzer": "^2.9.1", - "webpack-sources": "~1.1.0" + "webpack-sources": "~1.1.0", + "@types/chai": "^4.0.2", + "@types/mocha": "^2.2.41", + "@types/node": "^7.0.5" }, "scripts": { "e2e": "tsc -p e2e && mocha --opts ./e2e/config/mocha.opts", diff --git a/e2e/modal-navigation/tsconfig.json b/e2e/modal-navigation/tsconfig.json index e836e92ae..15a5ce832 100644 --- a/e2e/modal-navigation/tsconfig.json +++ b/e2e/modal-navigation/tsconfig.json @@ -24,6 +24,6 @@ "exclude": [ "node_modules", "platforms", - "e2e" + "e2e" ] -} +} \ No newline at end of file diff --git a/tns-core-modules/ui/frame/frame.android.ts b/tns-core-modules/ui/frame/frame.android.ts index 1e42dfc2a..cb471e4c5 100644 --- a/tns-core-modules/ui/frame/frame.android.ts +++ b/tns-core-modules/ui/frame/frame.android.ts @@ -176,16 +176,23 @@ export class Frame extends FrameBase { } } + _onRootViewReset(): void { + this.disposeCurrentFragment(); + super._onRootViewReset(); + } + onUnloaded() { + this.disposeCurrentFragment(); + super.onUnloaded(); + } + + private disposeCurrentFragment(){ if (this._currentEntry && this._currentEntry.fragment) { const manager: android.app.FragmentManager = this._getFragmentManager(); - const transaction = manager.beginTransaction(); transaction.remove(this._currentEntry.fragment); transaction.commitAllowingStateLoss(); } - - super.onUnloaded(); } private createFragment(backstackEntry: BackstackEntry, fragmentTag: string): android.app.Fragment {