Skip to content

docs: update guide viewer title when route params change - #33878

Open
MeAkib wants to merge 1 commit into
angular:mainfrom
MeAkib:docs/guide-viewer-title-on-param-change
Open

MeAkib wants to merge 1 commit into
angular:mainfrom
MeAkib:docs/guide-viewer-title-on-param-change

Conversation

@MeAkib

@MeAkib MeAkib commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

GuideViewer subscribed to the route params to resolve the current guide, but only set the page title once in ngOnInit. Since the router reuses the component when only the :id param changes, navigating from one guide to another in-app would update the rendered guide while leaving the browser title pointing at the previous one.

This isn't reachable today because guide-to-guide links in the markdown are absolute URLs that trigger a full page load, but it would surface as soon as an in-app link between guides is added.

Changes:

  • Set the page title inside the params subscription, next to where the guide is resolved, so both stay in sync on every param emission.
  • Remove the now-redundant ngOnInit and the OnInit interface.
  • Tie the params subscription to the component's lifetime with takeUntilDestroyed(), matching the pattern used in ComponentViewer.
  • Switch the spec's mocked params to a BehaviorSubject and add tests covering the initial title and the title after a param change.

`GuideViewer` subscribed to the route params to resolve the current guide,
but only set the page title once in `ngOnInit`. Since the router reuses the
component when only the `:id` param changes, navigating from one guide to
another in-app would update the rendered guide while leaving the browser
title pointing at the previous one.

This isn't reachable today because guide-to-guide links in the markdown are
absolute URLs that trigger a full page load, but it would surface as soon
as an in-app link between guides is added.

Changes:
- Set the page title inside the params subscription, next to where the
  guide is resolved, so both stay in sync on every param emission.
- Remove the now-redundant `ngOnInit` and the `OnInit` interface.
- Tie the params subscription to the component's lifetime with
  `takeUntilDestroyed()`, matching the pattern used in `ComponentViewer`.
- Switch the spec's mocked `params` to a `BehaviorSubject` and add tests
  covering the initial title and the title after a param change.
@angular-robot angular-robot Bot added the area: docs Related to the documentation label Sep 25, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: docs Related to the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant