diff --git a/CHANGELOG.md b/CHANGELOG.md index ac1f29fef..91fa22463 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ + +## [5.0.4](https://github.com/NativeScript/NativeScript/compare/5.0.3...5.0.4) (2018-11-26) + + +### Bug Fixes + +* **android-fragment:** child already has a parent ([#6589](https://github.com/NativeScript/NativeScript/issues/6589)) ([5b9b335](https://github.com/NativeScript/NativeScript/commit/5b9b335)) +* **back-navigation:** app freeze on going back in parent frame with states ([#6595](https://github.com/NativeScript/NativeScript/issues/6595)) ([fc1f8c1](https://github.com/NativeScript/NativeScript/commit/fc1f8c1)) + + + ## [5.0.3](https://github.com/NativeScript/NativeScript/compare/5.0.2...5.0.3) (2018-11-20) diff --git a/tns-core-modules/package.json b/tns-core-modules/package.json index 13acc0d54..9fe85da7d 100644 --- a/tns-core-modules/package.json +++ b/tns-core-modules/package.json @@ -1,7 +1,7 @@ { "name": "tns-core-modules", "description": "Telerik NativeScript Core Modules", - "version": "5.0.3", + "version": "5.0.4", "homepage": "https://www.nativescript.org", "repository": { "type": "git", diff --git a/tns-core-modules/ui/frame/frame-common.ts b/tns-core-modules/ui/frame/frame-common.ts index a86798ee4..5533f98d1 100644 --- a/tns-core-modules/ui/frame/frame-common.ts +++ b/tns-core-modules/ui/frame/frame-common.ts @@ -616,7 +616,7 @@ export function goBack(): boolean { if (parentFrame && parentFrame.canGoBack()) { parentFrameCanGoBack = true; } else { - parentFrame = getAncestor(top, "Frame"); + parentFrame = getAncestor(parentFrame, "Frame"); } } diff --git a/tns-core-modules/ui/frame/frame.android.ts b/tns-core-modules/ui/frame/frame.android.ts index 81d6cf7fc..417d817bb 100644 --- a/tns-core-modules/ui/frame/frame.android.ts +++ b/tns-core-modules/ui/frame/frame.android.ts @@ -834,6 +834,24 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { entry.viewSavedState = null; } + // fixes 'java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first'. + // on app resume in nested frame scenarios with support library version greater than 26.0.0 + // HACK: this whole code block shouldn't be necessary as the native view is supposedly removed from its parent + // right after onDestroyView(...) is called but for some reason the fragment view (page) still thinks it has a + // parent while its supposed parent believes it properly removed its children; in order to "force" the child to + // lose its parent we temporarily add it to the parent, and then remove it (addViewInLayout doesn't trigger layout pass) + const nativeView = page.nativeViewProtected; + if (nativeView != null) { + const parentView = nativeView.getParent(); + if (parentView instanceof android.view.ViewGroup) { + if (parentView.getChildCount() === 0) { + parentView.addViewInLayout(nativeView, -1, new org.nativescript.widgets.CommonLayoutParams()); + } + + parentView.removeView(nativeView); + } + } + return page.nativeViewProtected; } @@ -873,24 +891,6 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { traceError(`${fragment}.onDestroy: entry has no resolvedPage`); return null; } - - // fixes 'java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first'. - // on app resume in nested frame scenarios with support library version greater than 26.0.0 - // HACK: this whole code block shouldn't be necessary as the native view is supposedly removed from its parent - // right after onDestroyView(...) is called but for some reason the fragment view (page) still thinks it has a - // parent while its supposed parent believes it properly removed its children; in order to "force" the child to - // lose its parent we temporarily add it to the parent, and then remove it (addViewInLayout doesn't trigger layout pass) - const nativeView = page.nativeViewProtected; - if (nativeView != null) { - const parentView = nativeView.getParent(); - if (parentView instanceof android.view.ViewGroup) { - if (parentView.getChildCount() === 0) { - parentView.addViewInLayout(nativeView, -1, new org.nativescript.widgets.CommonLayoutParams()); - } - - parentView.removeView(nativeView); - } - } } @profile diff --git a/tns-platform-declarations/package.json b/tns-platform-declarations/package.json index 2ba61568c..bb7873d25 100644 --- a/tns-platform-declarations/package.json +++ b/tns-platform-declarations/package.json @@ -1,6 +1,6 @@ { "name": "tns-platform-declarations", - "version": "5.0.3", + "version": "5.0.4", "description": "Platform-specific TypeScript declarations for NativeScript for accessing native objects", "main": "", "scripts": {