Skip to content

fix(router): Fix _lastPathIndex in deeply nested empty paths - #22394

Closed
adriensamson wants to merge 3 commits into
angular:masterfrom
adriensamson:fix-empty-path-index
Closed

adriensamson wants to merge 3 commits into
angular:masterfrom
adriensamson:fix-empty-path-index

Conversation

@adriensamson

Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] angular.io application / infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

See #13011 (comment) and #13011 (comment)

When an empty path is deeply nested, its _lastPathIndex is too high and relative nagivation to its parent needs lot of additional '../'

Issue Number: #13011

What is the new behavior?

_lastPathIndex (computed from _segmentIndexShift) is correct and relative navigation works as expected

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@Jordan-Hall

Copy link
Copy Markdown
Contributor

@adriensamson This pull request appears to effect named outlet. using RouterLink in a named outlet makes the URL (../../) and not up a level correctly. It appears only to go up on the routing tree.

However it does fix the issue regarding primary routes

@djleonskennedy

Copy link
Copy Markdown

Any news ?

@jasonaden
jasonaden self-requested a review May 22, 2018 22:44
@jonrimmer

Copy link
Copy Markdown
Contributor

Please, please, please merge this. I do not understand how something as fundamental as relative navigation can be left broken for years. The Angular docs even recommend using pathless routes like this, and they do not work properly!?

@jasonaden
jasonaden force-pushed the fix-empty-path-index branch from 42b2c6d to 0ff8773 Compare July 11, 2018 17:26
@jasonaden

Copy link
Copy Markdown
Contributor

@adriensamson I know this has been sitting a while, but I'm taking a look at it.

My concern is that, while this is a bug fix, it will break apps that are currently using the extra ../ to solve this problem. Even though it's a bug fix, if it will possibly break apps that are using the workaround, we need to put it behind a flag.

I went ahead and added the flag, and we will remove that in v7 to make this behavior the default. I rebased and force pushed back to your PR branch.

Thanks a lot for the fix. This should make relative routing much less confusing for users.

@jasonaden

Copy link
Copy Markdown
Contributor

Presubmit

@jasonaden jasonaden left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@jasonaden jasonaden added the action: merge The PR is ready for merge by the caretaker label Jul 11, 2018
@ngbot

ngbot Bot commented Jul 11, 2018

Copy link
Copy Markdown

I see that you just added the PR action: merge label, but the following checks are still failing:
    failure missing required label: "PR target: *"
    pending status "continuous-integration/travis-ci/pr" is pending

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@jasonaden jasonaden added the target: patch This PR is targeted for the next patch release label Jul 11, 2018
@sarunint

Copy link
Copy Markdown
Contributor

Just for my curious, has the named-outlet issue mentioned by @Jordan-Hall been solved?

@matsko

matsko commented Jul 12, 2018

Copy link
Copy Markdown
Contributor

@adriensamson please rebase so that it can land in patch.

@sarunint

Copy link
Copy Markdown
Contributor

One more note, since @jasonaden refactored this to a flag in the router, shouldn't this be a feat, rather than a fix?

@adriensamson
adriensamson force-pushed the fix-empty-path-index branch from 5f0b70e to e4d8f74 Compare July 13, 2018 15:35
@adriensamson

Copy link
Copy Markdown
Contributor Author

Thank you @jasonaden for your help.
@matsko I have just rebased and fixed conflicts with master.

@vicb vicb added merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note action: merge The PR is ready for merge by the caretaker labels Jul 23, 2018
@vicb

vicb commented Jul 23, 2018

Copy link
Copy Markdown
Contributor

@jasonaden @adriensamson This patch does not apply cleanly on the 6.0.x branch and the PR is marked as master + patch (6.0.x).

What I would suggest is to mark this PR as master only and create a new PR for 6.0.x with the conflicts resolved. They would both be merged at the same time.

Makes sense ?

@vicb vicb added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Jul 23, 2018
@jasonaden

Copy link
Copy Markdown
Contributor

@vicb I'll work with you on merging this one to make sure the rebase is clean.

@jasonaden jasonaden added target: major This PR is targeted for the next major release action: merge The PR is ready for merge by the caretaker jira: sync and removed target: patch This PR is targeted for the next patch release action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note jira: sync labels Jul 24, 2018
@vicb vicb added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Jul 25, 2018
@vicb

vicb commented Jul 25, 2018

Copy link
Copy Markdown
Contributor

merge-assistance: wainting on the PR for the patch branch to be ready before merging

@jasonaden jasonaden mentioned this pull request Jul 25, 2018
@vicb vicb closed this in 968f153 Jul 25, 2018
@marcwhitbread

Copy link
Copy Markdown

I can't tell if this is in 6.0.x or not. Was the patch trashed?

@sarunint

sarunint commented Aug 2, 2018

Copy link
Copy Markdown
Contributor

@marcwhitbread It's not in 6.0.x, since it touches the public API.

@marcwhitbread

Copy link
Copy Markdown

@sarunint thanks for the reply. I apologize in advance for another stupid question... How would i find out what version received this pr? 6.1? 7?

@sarunint

sarunint commented Aug 4, 2018

Copy link
Copy Markdown
Contributor

It's 6.1.

@dirkluijk

Copy link
Copy Markdown
Contributor

Added #25609 to make this the default for Angular 7.

@dirkluijk

Copy link
Copy Markdown
Contributor

Seems to be broken in Angular 7: #26983.

I don't see how other recent changes could possibly interfere with this.

@angular-automatic-lock-bot

Copy link
Copy Markdown

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.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: router cla: yes merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.