Nativescript: `alert` Dialog not showing on the second modal.

Created on 17 Jun 2019  路  4Comments  路  Source: NativeScript/NativeScript

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 5.4.0
  • Cross-platform modules: 5.4.2
  • Android Runtime: not needed (im testing on iOS)
  • iOS Runtime: 5.4.1

Describe the bug
dialogs like alert and prompt not showing on the 2nd modal opened by the first modal. But when I try to show the alert from the first modal it works as expected.

To Reproduce
try the sample project.

Expected behavior
It should open the dialogs regardless of what modal.

Sample project
SampleNestedModlWithDialog.zip

Additional text
I don't know if I'm doing it right on how to call the 2nd modal, or maybe it's because the ios runtime is not updated to the latest. But I'll leave a sample project for you guys to see.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

backlog bug modal-page ios

Most helpful comment

I found a fix for this. In tns-code-modules/ui/dialogs/dialogs.ios.js showUIAlertController does not work for modals. Method finds Top view, but never searches for active modal. It tries to open dialog on parent window of modal and fails (need more investigation to be sure if it fails or just cannot be opened, because another modal is present). You need to add:

if (viewController.presentedViewController) { viewController = viewController.presentedViewController; }

after row 194:

var viewController = currentView.ios;

Read more about this in: https://stackoverflow.com/questions/6131205/how-to-find-topmost-view-controller-on-ios/12684721#12684721

If I will have time, I will create a PR during the weekend

All 4 comments

The issue is reproducible on iOS (works as expected on Android).

thanks for the quick reply :)

I found a fix for this. In tns-code-modules/ui/dialogs/dialogs.ios.js showUIAlertController does not work for modals. Method finds Top view, but never searches for active modal. It tries to open dialog on parent window of modal and fails (need more investigation to be sure if it fails or just cannot be opened, because another modal is present). You need to add:

if (viewController.presentedViewController) { viewController = viewController.presentedViewController; }

after row 194:

var viewController = currentView.ios;

Read more about this in: https://stackoverflow.com/questions/6131205/how-to-find-topmost-view-controller-on-ios/12684721#12684721

If I will have time, I will create a PR during the weekend

@NickIliev Created PR

Was this page helpful?
0 / 5 - 0 ratings