Skip to content

docs(angular): correct OnPush guidance in lifecycle note - #4694

Merged
ShaneK merged 6 commits into
mainfrom
FW-7725
Sep 2, 2026
Merged

docs(angular): correct OnPush guidance in lifecycle note#4694
ShaneK merged 6 commits into
mainfrom
FW-7725

Conversation

@ShaneK

@ShaneK ShaneK commented Sep 2, 2026

Copy link
Copy Markdown
Member

What's currently wrong

The lifecycle page has said for years that a component using ion-nav or ion-router-outlet shouldn't use OnPush, and that setting it will stop ngOnInit from firing. That's wrong on a couple of counts. The ngOnInit part isn't true in either change detection mode, and ion-nav was never affected either, because its pages get attached as root views instead of as children of the component hosting the nav. The page also never explained the why, which is what #1758 was asking for back in 2020.

What's changing and why

When Angular runs change detection it walks down from the root of your app, and a clean OnPush component stops the walk there and skips everything underneath it. So if any component above your ion-router-outlet is OnPush, the routed page inside it never gets checked, and a plain field you set after an await won't render. On Angular 18 through 21 that only happens if you set OnPush yourself. Angular 22 makes OnPush the default for any component that doesn't declare a strategy, so it can now happen without you touching anything.

We fixed our side of it in ionic-team/ionic-framework#31414, where every Ionic component declares a strategy explicitly so ion-router-outlet and ion-tabs stay eager. This PR helps users understand why if they happen to be using zone.js, Angular 22, and plain fields. The lifecycle note now says which components have to stay eager and what your options are if you'd rather not do that. The zoneless guide gets a "Change detection on Angular 22" section with an app-root example.

Resolve zoneless.mdx: keep the Angular 22 change detection section from this
branch and take main's .md -> .mdx link rewrite. Also point the zoneless
links added on this branch at the new .mdx path.
@ShaneK
ShaneK requested a review from a team as a code owner September 2, 2026 13:56
@ShaneK
ShaneK requested a review from thetaPC September 2, 2026 13:56
@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ionic-docs Ready Ready Preview Sep 2, 2026 6:20pm UTC

Request Review

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

LGTM, minor suggestion to make it easier for devs to quickly read the info they need based on their version.

Comment thread docs/angular/lifecycle.mdx Outdated
Co-authored-by: Maria Hutt <thetaPC@users.noreply.github.com>
@ShaneK
ShaneK merged commit cd094cd into main Sep 2, 2026
4 checks passed
@ShaneK
ShaneK deleted the FW-7725 branch September 2, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants