question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Creating Dialog.alert inside .then((result) not working

See original GitHub issue

Hi!

When I use the scanner and the code scanned did not match a param an alert is triggered to let the user know the scan is wrong. So in the result I have the following line to test:

.then((result) => {
      const alertOptions = {
        title: 'Warning',
        message: 'Something terrible has happened.',
        okButtonText: 'Okay',
        cancelable: false // [Android only] Gets or sets if the dialog can be canceled by taping outside of the dialog.
      }

      Dialogs.alert(alertOptions).then(() => {
        console.log('Ok chosen!')
      })
    });

This bit of code results in the next warning/error:

Warning: Attempt to present <UIAlertController: 0x10309c000> on <QRCodeReaderViewController: 0x102468590> whose view is not in the window hierarchy!

No alert is showing up which is obvious if you look at the warning/error.

I’m using: “@angular/core”: “~11.2.5”, “@nativescript/core”: “8.0.2”, “nativescript-barcodescanner”: “^4.1.0”,

Anyone a suggestion how to fix this? Is it a scanner issue or do I do something wrong?

Thanks in advance for any answer!!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Rdevccommented, Apr 28, 2021

Got it, thank you!

presentInRootViewController: true

This was the issue… I’ve copied the code from GitHub and your last message got me thinking about the modal…

it looks like

Fullscreen: true or Fullscreen: false

is not doing anything but deleting excluding the “presentInroot” showed me an alert without any warning or error.

Maybe I’ll look into that in te future if I got some time and know how to debug the plugin but for now its ok for me.

It’s up to you if you want this issue to be open to work on it later or close it.

Kind regards.

0reactions
EddyVerbruggencommented, Apr 28, 2021

Oh that’s nice! Glad you found a way to make it disappear.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SweetAlert2 confirm dialog not working properly in onclick
Your code is fine. Looks like the page is refreshing because the button click is being treated as a form submission. You'll need...
Read more >
The neatest way to handle alert dialogs in React
So here we go. Everything we need is to render only 1 top-level modal at the root of our application and show it...
Read more >
Dialogs - Android Developers
A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill...
Read more >
Lesson 1: Using JavaScript to Show an Alert
Try modifying your showAlert() script with your own custom alert message. Then test it to be sure it works. Using the onclick event....
Read more >
Window.alert() - Web APIs - MDN Web Docs - Mozilla
The alert dialog should be used for messages which do not require any response on the part of the user, other than the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found