Nativescript-angular: Modal : View already has a parent

Created on 23 May 2017  路  2Comments  路  Source: NativeScript/nativescript-angular

Since the latest upgrade, I have this error popping when closing a modal

  • Context:
    I have a modal that can open another one.
    When I try to close the 2nd modal in order to come back to the first one (this._params.closeCallback), the app breaks with this stacktrace
1   0x102a2771b NativeScript::FFICallback<NativeScript::ObjCMethodCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*)
2   0x1030fc15e ffi_closure_unix64_inner
3   0x1030fca92 ffi_closure_unix64
4   0x103e22073 -[UIViewController __viewWillAppear:]
5   0x103df7c37 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke
6   0x103e2b007 +[UIViewController _scheduleTransition:]
7   0x103df777b -[UIPresentationController runTransitionForCurrentState]
8   0x103df5866 -[UIPresentationController _dismissWithAnimationController:interactionController:target:didEndSelector:]
9   0x103e33571 __99-[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:]_block_invoke
10  0x103d30d3e +[UIView(Animation) performWithoutAnimation:]
11  0x103e33374 -[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:]
12  0x103d30d3e +[UIView(Animation) performWithoutAnimation:]
13  0x103e32fc6 -[UIViewController _dismissViewControllerWithTransition:from:completion:]
14  0x103e2af4c +[UIViewController _performWithoutDeferringTransitions:]
15  0x103e32559 -[UIViewController dismissViewControllerWithTransition:completion:]
16  0x103e323e5 -[UIViewController dismissViewControllerWithTransition:completion:]
17  0x1030fc8ed ffi_call_unix64
18  0x12b47fe60
file:///app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:416:100: JS ERROR Error: View already has a parent. View: Page(4202) Parent: Frame(1)
May 23 14:37:31 MacBook-Pro-de-jpele SpringBoard[53868]: [KeyboardArbiter] HW kbd: Failed to set (null) as keyboard focus
May 23 14:37:31 MacBook-Pro-de-jpele com.apple.CoreSimulator.SimDevice.9F7C4BE5-B8EE-4513-866E-4E4EBE9E501E.launchd_sim[53848] (UIKitApplication:com.chronogolf.app.chronogolf[0x390c][53873][70604]): Service exited due to Segmentation fault: 11
May 23 14:37:31 MacBook-Pro-de-jpele backboardd[53869]: [Common] Unable to get short BSD proc info for 70604: No such process
May 23 14:37:31 MacBook-Pro-de-jpele backboardd[53869]: [Common] Unable to get proc info for 70604: Undefined error: 0
2:37:43 PM - File change detected. Starting incremental compilation...
question

Most helpful comment

Hi @jeremypele,
First of all, thank you for your interest in NativeScript.
I reviewed your case, however at the moment opening ModalPage from another ModalPage is not supported.
For your convenience, I have opened new feature request in NativeScript repository here, where also the other users could vote for this functionality. If there is an interest, this feature will be included for some of the next NativeScirpt versions. For further info, you could keep track the above-given issue.

In the meantime, I could suggest closing the first modalPage and the to open the other one, for further help you could also review the sample project attached to this issue.

All 2 comments

Hi @jeremypele,
First of all, thank you for your interest in NativeScript.
I reviewed your case, however at the moment opening ModalPage from another ModalPage is not supported.
For your convenience, I have opened new feature request in NativeScript repository here, where also the other users could vote for this functionality. If there is an interest, this feature will be included for some of the next NativeScirpt versions. For further info, you could keep track the above-given issue.

In the meantime, I could suggest closing the first modalPage and the to open the other one, for further help you could also review the sample project attached to this issue.

Thanks for your response @tsonevn.

I understand that it could be a bad practice but it's too bad it breaks now as router in modal aren't implemented yet (saw that it's coming in roadmap though).

Can't really go with closing/opening multiple modals in my case.
Nevermind I'll go with a modal wrapper containing multiple components + ngIf/ngSwitch

Was this page helpful?
0 / 5 - 0 ratings