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.

Nav.getActive() returns null if an overlay is shown

See original GitHub issue

Short description of the problem:

When I present an overlay (alert, popover etc.), the app’s NavController method getActive returns null.

What behavior are you expecting?

I don’t know whether it should return the underlying page or the active overlay, but returning null seems like a bug to me, especially when it returns the active page before the overlay is shown. It seems to me that it should return the active overlay, becuse nav.isActive(overlay) returns true.

Steps to reproduce:

  1. Present an overlay and wait for it’s promise
  2. Check the return result of app.getActiveNav().getActive()
app.getActiveNav().getActive(); // returns ViewController with the current page
alert.present().then(() => {
   app.getActiveNav().getActive(); // returns null
   app.getAciveNav().isActive(alert); // returns true
});

Which Ionic Version? 1.x or 2.x 2.0.0-beta.11

Run ionic info from terminal/cmd prompt: (paste output below) Cordova CLI: 6.1.1 Gulp version: CLI version 3.9.1 Gulp local: Local version 3.9.1 Ionic Framework Version: 2.0.0-beta.11 Ionic CLI Version: 2.0.0-beta.36 Ionic App Lib Version: 2.0.0-beta.19 OS: Node Version: v6.2.0

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
TomasKatzcommented, Aug 13, 2016

Please remove me from conversations of your development !!! I have nothing to with your company and your spamming mail with tens of mails a day. PLEASE STOP SENDING ME THESE MAILS !!!

On Aug 13, 2016 7:25 PM, “Jakub Beránek” notifications@github.com wrote:

I’m on vacation and won’t be able to test it until next week, sorry x)

However I would like to get the active view from a singleton service that manages the overlays and UI, so using an injected NavController directly isn’t an option there. Is it possible to get the active view from the root/active nav? It seems that it should be working, it returns the page correctly, however after an overlay is shown, it suddenly returns null.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/driftyco/ionic/issues/7609#issuecomment-239629209, or mute the thread https://github.com/notifications/unsubscribe-auth/AH3Ui5pM4VEbYOkUhG4Zo-ATiS6uXVAQks5qfe_6gaJpZM4JfV4l .

0reactions
adubovskycommented, Oct 21, 2016

Actually this is a problem and should be fixed in my opinion.

Example/usecase: our app is checking for some settings/whatever in the background (using setInterval). And when this check returns TRUE we want to show modal with some info. So the problem is app will be broken in case of another overlay is active at the moment. What can we do in such cases? I thought about using getActive().isOverlay flag, but it doesn’t work 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nav.getActive() returns null if an overlay is shown · Issue #7609
Short description of the problem: When I present an overlay (alert, popover etc.), the app's NavController method getActive returns null.
Read more >
Ionic 3 : Close modal with phone's back button - Stack Overflow
nav.getActive().instance : null; if (page && page.isRootPage) { Logger.
Read more >
NavController - Ionic API Documentation
Inserts an array of components into the nav stack at the specified index. The last component in the array will become instantiated as...
Read more >
leaflet - getActiveLayers for LeafletJS - GIS Stack Exchange
This plugin contains methods getActiveBaseLayer() and getActiveOverlayLayers() . The following, from vogdb's github page, demonstrates how ...
Read more >
Scripting API: RenderTexture.active - Unity - Manual
If the active RenderTexture is null everything is rendered in the main window. ... render texture RenderTexture.active = currentActiveRT; return tex; } } ......
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