Skip to content

feat(router): add navigationSource and restoredState to NavigationStart event - #21728

Closed
vsavkin wants to merge 1 commit into
angular:masterfrom
vsavkin:pass_navigation_id
Closed

vsavkin wants to merge 1 commit into
angular:masterfrom
vsavkin:pass_navigation_id

Conversation

@vsavkin

@vsavkin vsavkin commented Jan 23, 2018

Copy link
Copy Markdown
Contributor

Currently, NavigationStart there is no way to know if an navigation was triggered imperatively or via the location change. These two use cases should be handled differently for a variety of use cases (e.g., scroll position restoration). This PR adds a navigation source field and restored navigation id (passed to navigations triggered by a URL change).

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] 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?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[ ] No

Other information

@jasonaden
jasonaden requested a review from IgorMinar January 23, 2018 21:22

@IgorMinar IgorMinar 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.

this looks very good, we just need to tweak the public api a bit.

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.

NavigationSource is not exported but it's used as public api surface. is this intentional?

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.

I recommend inlining the string literal union into the public api + renaming the property to navigationTrigger (source sounds like the source URL, which this is not).

Comment thread packages/router/src/events.ts Outdated

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.

why no docs?

Comment thread packages/router/src/events.ts Outdated

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.

why no docs?

@IgorMinar IgorMinar added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews area: router hotlist: google labels Jan 23, 2018

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.

please add docs for the navigationId and what is its significance.

@vsavkin

vsavkin commented Jan 24, 2018

Copy link
Copy Markdown
Contributor Author
  • I added the missing docs.
  • I renamed NavigationSource into NavigationTrigger.
  • I exported NavigationTrigger instead of inlining it. Mainly cause it is already used in a handful of places in the router itself. Inlining will result in a lot of duplication.

…rt event

Currently, NavigationStart there is no way to know if an navigation was triggered imperatively or via the location change. These two use cases should be handled differently for a variety of use cases (e.g., scroll position restoration). This PR adds a navigation source field and restored navigation id (passed to navigations triggered by a URL change).
@jasonaden

Copy link
Copy Markdown
Contributor

I updated to remove the NavigationTrigger event from the external API. This is for documentation, so looking at this event on angular.io you will see the values you can use rather than the type name.

@jasonaden jasonaden added action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Jan 26, 2018
@mhevery mhevery closed this in 3b7bab7 Jan 26, 2018

@IgorMinar IgorMinar 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.

this got submitted prematurely by accident. but all my comments were resolved so LGTM. thanks Victor.

jasonaden added a commit to jasonaden/angular that referenced this pull request Jan 27, 2018
…gationStart event (angular#21728)"

This reverts commit 3b7bab7. Will be re-merged after fixing integration of minor breaking change.
jasonaden pushed a commit to jasonaden/angular that referenced this pull request Jan 29, 2018
…rt event (angular#21728)

Currently, NavigationStart there is no way to know if an navigation was triggered imperatively or via the location change. These two use cases should be handled differently for a variety of use cases (e.g., scroll position restoration). This PR adds a navigation source field and restored navigation id (passed to navigations triggered by a URL change).

PR Close angular#21728
@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 13, 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 hotlist: google target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants