Ionic-framework: Bug: Page transistion error not showing if IonViewCanEnter is used

Created on 10 Feb 2017  路  8Comments  路  Source: ionic-team/ionic-framework

Ionic version: (check one with "x")
[ ] 1.x
[x ] 2.x

I'm submitting a ... (check one with "x")
[x ] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:
Compilation error on a page is not outputted in case IonViewCanEnter is utilized as it only returns true/false. While the developer may be caught unawares and would try to fiddle around with promise in IonViewCanEnter when the error would be somewhere else.

Expected behavior:
IonViewCanEnter should return the promise output.

Steps to reproduce:
http://plnkr.co/edit/ieks9V?p=preview

stale issue

Most helpful comment

The issue seems to be present in ionic v2.3.0
Discussion can be seen here
https://forum.ionicframework.com/t/uncaught-in-promise-false-when-using-ionviewcanenter/84507/14

All 8 comments

Thanks for opening an issue, we will take a look into this.

+1. It would be good to have the promise output returned, e.g. when having multiple reasons for rejecting and then appropriately handle it.

The issue seems to be present in ionic v2.3.0
Discussion can be seen here
https://forum.ionicframework.com/t/uncaught-in-promise-false-when-using-ionviewcanenter/84507/14

Well im glad i didnt update my ionic. My whole App wouldnt work anymore with this issue. Please fix it fast!

Unfortunately, I can confirm this issue. It is not possible to give a negative result with a promise from ionViewCanEnter. It definitely works for me with ionViewCanLeave tough...

This is pretty old, any updates on this issue?
Currently I found a workaround, I implemented an app guard using viewWillEnter but I am not satisfied with its behavior, it performs many times per navigation, after filtering child pages it performs two times per change!

    this.appCtrl.viewWillEnter
      .filter((page: ViewController) => !page.enableBack())
      .subscribe((page: ViewController) => {

        /** TODO: Check why it performs two times per change */

        /** Check if user is authenticated */
        if (!this.state.authenticated && page.name !== 'AccessPage') {
          this.nav.setRoot('AccessPage');
        }
      });

This is also causing issues with our app as well. I don't want the user to navigate away and lose their data without warning first. We return a promise from the ionViewCanLeave and resolve if they say "ok" and reject if they say "cancel". The resolve works fine but the reject throws a:

"Uncaught (in promise) false"

The exact same thing happens with the code in this repo: https://github.com/ionic-team/ionic/blob/efd54750bf44b622a20078be02a2335aabc6dcec/src/components/tabs/test/advanced/pages/tabs-page/tabs.ts#L43

Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Thank you for using Ionic!

Was this page helpful?
0 / 5 - 0 ratings