Skip to content

Router.navigate doesnt work with relative route unless that route is currently active #38276

Closed

Description

@slubowsky

🐞 bug report

Affected Package

The issue is caused by package @angular/router

Is this a regression?

Dont know

Description

When using Router.navigate and passing a relative route in NavigationExtras, navigation silently fails unless the relative route is CURRENTLY active. Documentation does not state that relativeTo route must currently be active (though the class type is called ActivatedRoute), that restriction would seem to be unwanted, and in any event a silent failure to navigate is certainly not expected behavior.

🔬 Minimal Reproduction

https://github.com/slubowsky/router-test

  1. Run app.
  2. Navigate to one by clicking the "one" button. This sets up a navigation function in NavigationService to perform navigation when called.
  3. Click "Go to three using navigation service" button. The navigation function is called and app successfully navigates as expected.
  4. Navigate to two by clicking the "two" button.
  5. Click "Go to three using navigation service" button. The same navigation function that previously successfully navigated is called again but this time app silently fails to navigate.

🔥 Exception or Error

🌍 Your Environment

Angular Version:


Angular CLI: 10.0.4
Node: 14.6.0
OS: win32 x64

Angular: 10.0.5
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1000.4
@angular-devkit/build-angular     0.1000.4
@angular-devkit/build-optimizer   0.1000.4
@angular-devkit/build-webpack     0.1000.4
@angular-devkit/core              7.3.10
@angular-devkit/schematics        7.3.10
@angular/cdk                      10.1.1
@angular/cli                      10.0.4
@ngtools/webpack                  10.0.4
@schematics/angular               8.3.28
@schematics/update                0.1000.4
rxjs                              6.6.0
typescript                        3.9.7
webpack                           4.43.0

Activity

  1. added this to the needsTriage milestone on Jul 28, 2020
  2. modified the milestones: needsTriage, Backlog on Aug 4, 2020
  3. added
    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
    and removed on Oct 1, 2020
  4. angular-automatic-lock-bot commented on Jun 24, 2022

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions