Skip to content

NavCtroller navigateForward and navigateBack broken after refactor by commit #8ee9205 #17103

Closed

Description

@kevin-barrientos

4.0.0-rc.1:

I'm submitting a ...

[x] bug report
[ ] feature request

Current behavior:
The methods navigateForward and navigateBack of the NavController returns void instead of returning the value returned by navigate. See commit 8ee9205#diff-68c0efda98168f58059a80de770871e5

This is a breaking change not listed in the release notes.

Expected behavior:
In Ionic 4.0.0-rc.0 these methods returned a promise that resolved when the navigation was successfull. These is usefull to close dialogs or menus after a navigation has been completed.

Steps to reproduce:

  1. Start a fresh new project with two pages.
  2. Inject NavController on the first page and use it to navigate forward (i.e. this.navCtrl.navigateForward('secondPage').then(() => console.log('succeded')).

Related code:

  • Ionic 4.0.0-rc.0 NavController source code:
  navigateForward(url: string | UrlTree | any[], options: NavigationOptions = {}) {
    this.setDirection('forward', options.animated, options.animationDirection);
    if (Array.isArray(url)) {
      return this.router!.navigate(url, options);
    } else {
      return this.router!.navigateByUrl(url, options);
    }
  }
  • Ionic 4.0.0-rc.1 NavController source code
  navigateForward(url: string | UrlTree | any[], options: NavigationOptions = {}) {
    this.setDirection('forward', options.animated, options.animationDirection);
    this.navigate(url, options);
  }

  navigate(url: string | UrlTree | any[], options: NavigationOptions) {
    if (Array.isArray(url)) {
      return this.router!.navigate(url, options);
    } else {
      return this.router!.navigateByUrl(url, options);
    }
  }

Ionic info:

Ionic:

   ionic (Ionic CLI)             : 4.7.1 (C:\Users\Kevin Barrientos\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.0.0-rc.1
   @angular-devkit/build-angular : 0.12.1
   @angular-devkit/schematics    : 7.0.6
   @angular/cli                  : 7.0.6
   @ionic/angular-toolkit        : 1.2.0

Cordova:

   cordova (Cordova CLI) : 8.1.1 ([email protected])
   Cordova Platforms     : android 7.1.2
   Cordova Plugins       : not available

System:

   NodeJS : v10.15.0 (C:\Program Files\nodejs\node.exe)
   npm    : 6.4.1
   OS     : Windows 10

Activity

  1. changed the title [-]NavCtroller navigateForward and navigateBack broken after refactor[/-] [+]NavCtroller navigateForward and navigateBack broken after refactor by commit 8ee9205[/+] on Jan 14, 2019
  2. changed the title [-]NavCtroller navigateForward and navigateBack broken after refactor by commit 8ee9205[/-] [+]NavCtroller navigateForward and navigateBack broken after refactor by commit #8ee9205[/+] on Jan 14, 2019
  3. manucorporat commented on Jan 14, 2019

    @manucorporat
    Contributor

    Thanks for the issue! already created a PR that fixes it: #17106

  4. ionitron-bot commented on Feb 13, 2019

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. 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.

  5. locked and limited conversation to collaborators on Feb 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions