-
Notifications
You must be signed in to change notification settings - Fork 26.4k
fix(router): ensure routerLinkActive updates when associated routerLinks change #38349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
7479599
to
817591f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (just a couple nits) 👍
Reviewed-for: public-api
You can preview 3abec29 at https://pr38349-3abec29.ngbuilds.io/. |
You can preview de6aaec at https://pr38349-de6aaec.ngbuilds.io/. |
You can preview 87ea2f1 at https://pr38349-87ea2f1.ngbuilds.io/. |
You can preview d0f41ba at https://pr38349-d0f41ba.ngbuilds.io/. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
0ae1d28
to
ffcefd8
Compare
You can preview ffcefd8 at https://pr38349-ffcefd8.ngbuilds.io/. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Reviewed-for: public-api
…nks change This commit introduces a new subscription in the `routerLinkActive` directive which triggers an update when any of its associated routerLinks have changes. `RouterLinkActive` not only needs to know when links are added or removed, but it also needs to know about if a link it already knows about changes in some way. Quick note that `from...mergeAll` is used instead of just a simple `merge` (or `scheduled...mergeAll`) to avoid introducing new rxjs operators in order to keep bundle size down. Fixes angular#18469
You can preview 95af0b8 at https://pr38349-95af0b8.ngbuilds.io/. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed-For: public-api
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed-for: public-api
@ContentChildren(RouterLink, {descendants: true}) links!: QueryList<RouterLink>; | ||
// TODO(issue/24571): remove '!'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally I am against removing these comments unless the !
is removed (somehow) or replacing the comment with a reason why the !
can be retained.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I guess Angular developers are aware that queries are only available after the appropriate hook has been called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thought process was that they could "technically" be undefined until afterContentInit
but are reliably initialized after that. And that we could really never make this ?
instead so the comment isn't really actionable in that way. I did some more reading in the issue report and found these guidelines that support keeping !
as well:
the field is reliably initialized, but TS cannot infer that (initialization can occur outside the ctor, for example), so ! should be kept.
#24571 (comment)
I think ContentChildren
and ViewChildren
could be considered "reliably initialized" after the correct lifecycle hooks.
If the field is annotated with @ViewChildren or @ContentChildren - Add back '!' - c).
…outerLinks change
You can preview e21e492 at https://pr38349-e21e492.ngbuilds.io/. |
…nks change (#38349) This commit introduces a new subscription in the `routerLinkActive` directive which triggers an update when any of its associated routerLinks have changes. `RouterLinkActive` not only needs to know when links are added or removed, but it also needs to know about if a link it already knows about changes in some way. Quick note that `from...mergeAll` is used instead of just a simple `merge` (or `scheduled...mergeAll`) to avoid introducing new rxjs operators in order to keep bundle size down. Fixes #18469 PR Close #38349
…routerLinks change (angular#38349)" This reverts commit e0e5c9f. Failures in Google tests were detected.
…nks change (angular#38349) This commit introduces a new subscription in the `routerLinkActive` directive which triggers an update when any of its associated routerLinks have changes. `RouterLinkActive` not only needs to know when links are added or removed, but it also needs to know about if a link it already knows about changes in some way. Quick note that `from...mergeAll` is used instead of just a simple `merge` (or `scheduled...mergeAll`) to avoid introducing new rxjs operators in order to keep bundle size down. Fixes angular#18469 PR Close angular#38349
…routerLinks change (angular#38349)" (angular#38511) This reverts commit e0e5c9f. Failures in Google tests were detected. PR Close angular#38511
…ociated routerLinks change (angular#38349)" (angular#38511)" This reverts commit 25ba8f4.
…routerLinks change (angular#38349)" This reverts commit e7f5e84.
…nks change (angular#38349) This commit introduces a new subscription in the `routerLinkActive` directive which triggers an update when any of its associated routerLinks have changes. `RouterLinkActive` not only needs to know when links are added or removed, but it also needs to know about if a link it already knows about changes in some way. Quick note that `from...mergeAll` is used instead of just a simple `merge` (or `scheduled...mergeAll`) to avoid introducing new rxjs operators in order to keep bundle size down. Fixes angular#18469 PR Close angular#38349
…routerLinks change (angular#38349)" (angular#38511) This reverts commit e0e5c9f. Failures in Google tests were detected. PR Close angular#38511
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This commit introduces a new subscription in the
routerLinkActive
directive which triggers an updatewhen any of its associated routerLinks have changes.
RouterLinkActive
not only needs to know whenlinks are added or removed, but it also needs to know about if a link it already knows about
changes in some way.
Quick note that
from...mergeAll
is used instead of just a simplemerge
(orscheduled...mergeAll
) to avoid introducing new rxjsoperators in order to keep bundle size down.
Fixes #18469