angular / angular/angular

Add canDeactivateChild guard

Open
#11,836 27 comments 99 reactions 0 assignees View on GitHub
area: router feature feature: under consideration freq2: medium
Dominant language
TypeScript
Stars
101k
Forks
27.5k
Avg merge
1d 19h
Merged PRs (30d)
288

Description

**I'm submitting a ...** (check one with "x")

```
[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
```

**What is the motivation / use case for changing the behavior?**
There is already a canActivateChild guard. Having the symmetric guard is equally important. Not sure why this wasn't added at the same time. We have many scenarios where we need to protect child routes from navigating away if they have pending unsaved changes. That's currently only possible by putting a canDeactivate guard on each child route.
- **Angular version:** Latest
- **Browser:** all
- **Language:** all

Contributor guide

Open the contributing guide

Research direction

The issue proposes a new Angular routing guard, canDeactivateChild, symmetric with the existing canActivateChild guard. Start by locating the routing implementation and tests for canActivateChild; the issue names no files or tests, so first establish the API and expected behavior for protecting child routes with pending unsaved changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.