Deliver web apps with confidence 🚀
Find a file
Andrew Scott c5d0bd4966 fix(router): Prevent URL flicker when new navigations cancel ongoing ones (#43496)
This bit of code is problematic for several reasons:
1. AngularJS-specific handling should not exist in core router code if it can be avoided.
It's not something that should complicated the code long-term
2. It causes URL flickering (the `replace: /` really does happen and can be observed)
3. The original intent was likely for the URL to not actually change;
since the Router only initially supported 'deferred' navigations, this would _usually_ be the case.
4. It actually causes observers of URL changes more problems in handling changes
because the router is already about to process another navigation request.
Notice that when using `'computed'` restoration logic, we do not reset the URL
because it would cause another location change event and conflict with the new navigation.
5. It only resets the browser URL but does nothing to sync the rest of the internal state of the router.
6. It makes guards which call `router.navigate()` behave _slightly_ differently
than guard which return `UrlTree`. Guards which return `UrlTree` do not reset the
URL, but instead just trigger a new navigation.
7. It resets the entire URL rather than just the portion that the
   `UrlHandlingStrategy` is configured to handle. Theoretically, the
   Router could be configured to only handle a part of the URL so failed
   navigations should not reset parts it is not configured to touch.
   Note that this is actually a problem in other places in the router as
   well where `resetState` is not called before
   `resetUrlToCurrentUrlTree`.

As a nice benefit, when `urlUpdateStrategy` is set to `'eager'`, this
makes #17004 possible.

BREAKING CHANGE:
The router will no longer replace the browser URL when a new navigation
cancels an ongoing navigation. This often causes URL flicker and was
only in place to support some AngularJS hybrid applications. Hybrid
applications which rely on the `navigationId` being present on initial
navigations that were handled by the Angular router should instead
subscribe to `NavigationCancel` events and perform the
`location.replaceState` themselves to add `navigationId` to the Router
state.
In addition, tests which assert `urlChanges` on the `SpyLocation` may
need to be adjusted to account for the `replaceState` which is no longer
triggered.

PR Close #43496
2021-09-20 20:57:57 +00:00
.circleci ci: avoid failures when yarn unlinks bazelisk in windows jobs (#43373) 2021-09-07 18:44:00 +00:00
.devcontainer build: upgrade to node 14 (#41544) 2021-04-14 09:40:17 -07:00
.github build: Exclude tsconfig-tsec.json files from sync with g3 (#43108) 2021-09-13 14:45:57 -07:00
.husky build: remove unnecessary husky gitignore file (#42870) 2021-07-19 17:31:55 -07:00
.ng-dev build: check .ng-dev tool configuration in CI (#43322) 2021-09-02 21:18:36 +00:00
.vscode build: use "outFiles" in .vscode/launch.json to speed up debugging sessions (#39848) 2020-12-17 11:23:13 -08:00
.yarn build: update to yarn v1.22.10 (#40562) 2021-01-26 10:52:27 -08:00
aio docs: reviewed tag added (#43493) 2021-09-20 17:09:50 +00:00
docs build(docs-infra): add sealed markers to classes in API pages (#42807) 2021-08-17 09:23:09 -07:00
goldens fix(docs-infra): bump aio size limit (#42800) 2021-09-09 11:17:00 -07:00
integration build: update bazel setup to latest versions (#43322) 2021-09-02 21:18:36 +00:00
modules build: remove dev-infra directory and migrate to relying on @angular/dev-infra-private-builds (#43061) 2021-08-16 10:44:27 -07:00
packages fix(router): Prevent URL flicker when new navigations cancel ongoing ones (#43496) 2021-09-20 20:57:57 +00:00
scripts ci: stop publishing snapshots to angular/dev-infra-private-builds (#43059) 2021-08-05 16:05:03 -07:00
third_party build: rename shims_for_IE.js -> shims_for_internal_tests.js (#43002) 2021-08-02 10:38:42 -07:00
tools build: Auto-gen tsec tsconfig files (#43440) 2021-09-17 17:17:34 +00:00
.bazelignore test: delete integration test for language service plugin (#41740) 2021-04-23 11:00:40 -07:00
.bazelrc build: remove dev-infra directory and migrate to relying on @angular/dev-infra-private-builds (#43061) 2021-08-16 10:44:27 -07:00
.bazelversion build: remove outdated note when updating bazel version (#42760) 2021-07-09 14:50:14 -07:00
.clang-format feat(tooling): Add a .clang-format for automated JavaScript formatting. 2015-04-02 08:44:34 -07:00
.editorconfig build: use https link to editorconfig.org in .editorconfig (#27664) 2018-12-18 09:30:09 -08:00
.gitattributes build: remove ts-api-guardian from repository (#42735) 2021-07-26 12:02:14 -07:00
.gitignore build: Turn tsec checks into bazel tests. (#43108) 2021-09-13 14:45:57 -07:00
.gitmessage build: remove dev-infra directory and migrate to relying on @angular/dev-infra-private-builds (#43061) 2021-08-16 10:44:27 -07:00
.mailmap build: add a Git .mailmap with my new name (#19550) 2017-10-09 14:35:30 -07:00
.npmrc build: rely on engines to prevent using npm for dependency install (#41477) 2021-04-07 12:05:01 -07:00
.nvmrc build: upgrade to node 14 (#41544) 2021-04-14 09:40:17 -07:00
.prettierrc ci: use prettier to format yml files (#42136) 2021-05-19 11:20:20 -07:00
.pullapprove.yml build: Auto-gen tsec tsconfig files (#43440) 2021-09-17 17:17:34 +00:00
.yarnrc build: update to yarn v1.22.10 (#40562) 2021-01-26 10:52:27 -08:00
browser-providers.conf.js ci: remove IE11 from the list of browsers used during CI (#43002) 2021-08-02 10:38:42 -07:00
BUILD.bazel build: rename shims_for_IE.js -> shims_for_internal_tests.js (#43002) 2021-08-02 10:38:42 -07:00
CHANGELOG.md release: cut the v13.0.0-next.6 release (#43464) 2021-09-15 10:37:18 -07:00
CODE_OF_CONDUCT.md docs: add Discord as an official communication channel (#39149) 2020-10-14 10:23:15 -07:00
CONTRIBUTING.md build: remove dev-infra directory and migrate to relying on @angular/dev-infra-private-builds (#43061) 2021-08-16 10:44:27 -07:00
gulpfile.js build: convert CLDR locale extraction from Gulp to Bazel tool (#42230) 2021-07-16 12:44:59 -07:00
karma-js.conf.js build: rename shims_for_IE.js -> shims_for_internal_tests.js (#43002) 2021-08-02 10:38:42 -07:00
LICENSE docs: update the copyright notice date (#40707) 2021-02-16 10:04:23 -08:00
package.json release: cut the v13.0.0-next.6 release (#43464) 2021-09-15 10:37:18 -07:00
README.md docs: update tagline (#41922) 2021-05-03 10:04:05 -07:00
renovate.json ci: configure renovate to manage GitHub workflow updates (#43146) 2021-08-16 11:37:20 -07:00
test-events.js build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
test-main.js build: remove unnecessary polyfills from tests (#42567) 2021-06-14 14:14:41 -07:00
tsconfig-tslint.json build: remove dev-infra directory and migrate to relying on @angular/dev-infra-private-builds (#43061) 2021-08-16 10:44:27 -07:00
tslint.json build: remove dev-infra directory and migrate to relying on @angular/dev-infra-private-builds (#43061) 2021-08-16 10:44:27 -07:00
WORKSPACE build: update bazel setup to latest versions (#43322) 2021-09-02 21:18:36 +00:00
yarn.lock build: lock file maintenance (#43285) 2021-09-14 11:08:59 -07:00
yarn.lock.readme.md build: remove travisci leftovers (#27979) 2019-01-09 10:41:16 -08:00

Angular - The modern web developer's platform.

angular-logo
Angular is a development platform for building mobile and desktop web applications
using Typescript/JavaScript and other languages.

www.angular.io

Contributing Guidelines · Submit an Issue · Blog

CI status   Angular on npm   Discord conversation


Documentation

Get started with Angular, learn the fundamentals and explore advanced topics on our documentation website.

Advanced

Development Setup

Prerequisites

Setting Up a Project

Install the Angular CLI globally:

npm install -g @angular/cli

Create workspace:

ng new [PROJECT NAME]

Run the application:

cd [PROJECT NAME]
ng serve

Angular is cross-platform, fast, scalable, has incredible tooling, and is loved by millions.

Quickstart

Get started in 5 minutes.

Ecosystem

angular ecosystem logos

Changelog

Learn about the latest improvements.

Upgrading

Check out our upgrade guide to find out the best way to upgrade your project.

Contributing

Contributing Guidelines

Read through our contributing guidelines to learn about our submission process, coding rules and more.

Want to Help?

Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues labeled as help wanted or good first issue.

Code of Conduct

Help us keep Angular open and inclusive. Please read and follow our Code of Conduct.

Community

Join the conversation and help the community.

Love Angular badge

Love Angular? Give our repo a star ⬆️.