Skip to content

fix(router): Ensure newly resolved data is inherited by child routes#52167

Closed
atscott wants to merge 2 commits intoangular:mainfrom
atscott:makeDataInheritanceSane
Closed

fix(router): Ensure newly resolved data is inherited by child routes#52167
atscott wants to merge 2 commits intoangular:mainfrom
atscott:makeDataInheritanceSane

Conversation

@atscott
Copy link
Copy Markdown
Contributor

@atscott atscott commented Oct 11, 2023

The current way of computing a route's params and data recomputes inherited data from the inheritance root every time. When the inheritance strategy is "emptyOnly", this isn't necessarily the root of the tree, but some point along the way (it stops once it reaches an ancestor route with a component).

Instead, this commit updates parameter inheritance to only inherit data directly from the parent route (again, instead of recomputing all inherited data back to the inheritance root). The only requirement for making this work is that the parent route data has already calculated and updated its own inherited data. This was really already a requirement -- parents need to be processed before children.

In addition, the update to the inheritance algorithm in this commit requires more of an understanding that a resolver running higher up in the tree has to propagate inherited data downwards. The previous algorithm hid this knowledge because resolvers would recompute inherited data from the root when run. However, routes that did not have resolvers rerun or never had resolvers at all would not get the updated resolved data.

fixes #51934

@ngbot ngbot bot added this to the Backlog milestone Oct 11, 2023
@atscott atscott added target: patch This PR is targeted for the next patch release action: global presubmit The PR is in need of a google3 global presubmit labels Oct 11, 2023
@atscott atscott force-pushed the makeDataInheritanceSane branch 3 times, most recently from 1694217 to d982d88 Compare October 12, 2023 18:14
The current way of computing a route's params and data recomputes
inherited data from the inheritance root every time. When the
inheritance strategy is "emptyOnly", this isn't necessarily the root of
the tree, but some point along the way (it stops once it reaches an
ancestor route with a component).

Instead, this commit updates parameter inheritance to only inherit data
directly from the parent route (again, instead of recomputing all
inherited data back to the inheritance root). The only requirement for
making this work is that the parent route data has already calculated
and updated its own inherited data. This was really already a
requirement -- parents need to be processed before children.

In addition, the update to the inheritance algorithm in this commit
requires more of an understanding that a resolver running higher up in
the tree has to propagate inherited data downwards. The previous
algorithm hid this knowledge because resolvers would recompute inherited
data from the root when run. However, routes that did not have resolvers
rerun or never had resolvers at all would not get the updated resolved data.

fixes angular#51934
@atscott atscott force-pushed the makeDataInheritanceSane branch from d982d88 to c07c657 Compare October 12, 2023 21:04
@atscott
Copy link
Copy Markdown
Contributor Author

atscott commented Oct 16, 2023

Green TGP

I have some concerns with respect to how risky this is to fix. While the unit tests are coming back green, this could have production impact that isn't tested. Added the "risk: medium" label as a reminder/indicator to request merging & syncing to g3 on its own.

@atscott atscott requested a review from AndrewKushnir October 16, 2023 20:43
@atscott atscott marked this pull request as ready for review October 16, 2023 20:43
@atscott atscott added target: rc This PR is targeted for the next release-candidate action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note and removed target: patch This PR is targeted for the next patch release labels Oct 17, 2023
@atscott
Copy link
Copy Markdown
Contributor Author

atscott commented Oct 17, 2023

caretaker note: Green TGP linked above but still targeting RC rather than patch due to rollback risk. Please merge and sync on its own.

@dylhunn
Copy link
Copy Markdown
Contributor

dylhunn commented Oct 19, 2023

This PR was merged into the repository by commit 3278966.

dylhunn pushed a commit that referenced this pull request Oct 19, 2023
…52167)

The current way of computing a route's params and data recomputes
inherited data from the inheritance root every time. When the
inheritance strategy is "emptyOnly", this isn't necessarily the root of
the tree, but some point along the way (it stops once it reaches an
ancestor route with a component).

Instead, this commit updates parameter inheritance to only inherit data
directly from the parent route (again, instead of recomputing all
inherited data back to the inheritance root). The only requirement for
making this work is that the parent route data has already calculated
and updated its own inherited data. This was really already a
requirement -- parents need to be processed before children.

In addition, the update to the inheritance algorithm in this commit
requires more of an understanding that a resolver running higher up in
the tree has to propagate inherited data downwards. The previous
algorithm hid this knowledge because resolvers would recompute inherited
data from the root when run. However, routes that did not have resolvers
rerun or never had resolvers at all would not get the updated resolved data.

fixes #51934

PR Close #52167
@dylhunn dylhunn closed this in 3278966 Oct 19, 2023
@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 Nov 19, 2023
ChellappanRajan pushed a commit to ChellappanRajan/angular that referenced this pull request Jan 23, 2024
…ngular#52167)

The current way of computing a route's params and data recomputes
inherited data from the inheritance root every time. When the
inheritance strategy is "emptyOnly", this isn't necessarily the root of
the tree, but some point along the way (it stops once it reaches an
ancestor route with a component).

Instead, this commit updates parameter inheritance to only inherit data
directly from the parent route (again, instead of recomputing all
inherited data back to the inheritance root). The only requirement for
making this work is that the parent route data has already calculated
and updated its own inherited data. This was really already a
requirement -- parents need to be processed before children.

In addition, the update to the inheritance algorithm in this commit
requires more of an understanding that a resolver running higher up in
the tree has to propagate inherited data downwards. The previous
algorithm hid this knowledge because resolvers would recompute inherited
data from the root when run. However, routes that did not have resolvers
rerun or never had resolvers at all would not get the updated resolved data.

fixes angular#51934

PR Close angular#52167
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: global presubmit The PR is in need of a google3 global presubmit action: merge The PR is ready for merge by the caretaker area: router merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note risk: medium target: rc This PR is targeted for the next release-candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Child route data is not inherited from parent unless 'runGuardsAndResolvers' returns true

3 participants