fix(docs): errors following a full review of the app (#DS-5310)#1716
Merged
Conversation
Derive the sidenav's highlighted node from router NavigationEnd events instead of a one-time field initializer, so it no longer drifts after client-side navigation (added a regression spec). Also lands review lifecycle/signal cleanups for the docs app: - replace setTimeout timing hacks with afterNextRender (sidenav, tokens-overview) - migrate legacy decorators to signal APIs: input()/computed (stackblitz-button), output() (example/live-example viewers), viewChild() (live-example viewers) - remove a dead fileOrder input; guard the optional exampleElement query - harden structure.expiresAt to skip an invalid isNew date instead of throwing at import
…ent-viewer (#DS-5310) Return null from the scroll-container lookup and no-op in every consumer instead of dereferencing a non-null assertion that can lie, so setScrollPosition no longer throws on a page without a docs-component-viewer host. Also centralize the markdown pre/heading class names via CLASS_PREFIX (shared with tools/markdown-to-html), replacing the scattered string literals.
…DS-5310) Memoize getPropertyValue reads by (theme, token) so switching themes back and forth never re-reads a token via getComputedStyle; token values depend only on the active theme.
|
Visit the preview URL for this PR (updated for commit ebb38e6): https://koobiq-next--prs-1716-cd3fjgry.web.app (expires Mon, 13 Jul 2026 11:19:01 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: c9e37e518febda70d0317d07e8ceb35ac43c534c |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens up the docs app after a broader audit: it improves SSR/runtime robustness, centralizes docs UI i18n strings, moves analytics bootstrapping into Angular, adds targeted unit tests, and reduces initial bundle weight via route-level code splitting.
Changes:
- Centralized docs UI-chrome translations (
DOCS_TRANSLATIONS) and added at()helper onDocsLocaleStateto remove inline{ru/en}literals across templates. - Improved correctness/robustness: safer SSR window stubs, fixed leaking scroll listeners, safer anchor container handling, cache eviction on HTTP errors, and various OnPush/async CD fixes.
- Performance/ops: route lazy-loading via
loadComponent, token-value caching to reducegetComputedStylereads, and analytics script injection moved from inline HTML to an Angular initializer.
Reviewed changes
Copilot reviewed 61 out of 62 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Adds paths for src/* and a Jest-only stub for @koobiq/docs-examples. |
| eslint.config.js | Re-enables key template a11y lint rules as errors for apps/docs/**/*.html. |
| apps/docs/src/testing/docs-examples.stub.ts | Adds a lightweight test-only stub for the docs-examples package. |
| apps/docs/src/index.html | Removes inline metrika script; leaves noscript beacon and notes provider-based loading. |
| apps/docs/src/environments/environment.ts | Removes legacy environment file (no longer used by build config). |
| apps/docs/src/environments/environment.prod.ts | Removes legacy prod environment file (no longer used by build config). |
| apps/docs/src/config.server.ts | Expands SSR KBQ_WINDOW stub surface to avoid SSR crashes. |
| apps/docs/src/app/structure.ts | Adds validity tracking for isNew expiry dates and O(1) lookup maps for items/categories. |
| apps/docs/src/app/structure.spec.ts | Adds integrity tests for structure IDs, lookups, and ISO date validity. |
| apps/docs/src/app/services/title-strategy.ts | Introduces centralized router-driven <title> + meta + canonical management. |
| apps/docs/src/app/services/locale.ts | Fixes locale switching to preserve query/fragment by rebuilding commands from UrlTree; adds t() helper. |
| apps/docs/src/app/services/locale.spec.ts | Adds unit tests for locale parsing and navigation behavior. |
| apps/docs/src/app/services/i18n.ts | Adds centralized translation dictionary + docsTranslate. |
| apps/docs/src/app/services/i18n.spec.ts | Adds value-lock tests to prevent silent string changes during migration. |
| apps/docs/src/app/services/i18n.characterization.spec.ts | Adds characterization tests asserting rendered strings for selected components/services. |
| apps/docs/src/app/services/document-loader.ts | Evicts cache entries on HTTP error so failures don’t get replayed forever. |
| apps/docs/src/app/services/document-loader.spec.ts | Tests request de-duping and re-fetch behavior after errors. |
| apps/docs/src/app/services/doc-states.ts | Fixes potential scroll listener leaks and guards methods when elements aren’t registered. |
| apps/docs/src/app/services/doc-states.spec.ts | Adds tests ensuring re-registration tears down previous scroll listeners. |
| apps/docs/src/app/services/clipboard.ts | Introduces a single clipboard+toast service for consistent copy UX. |
| apps/docs/src/app/services/analytics.ts | Loads Yandex.Metrika via Angular initializer (browser-only, honors DNT). |
| apps/docs/src/app/routes.ts | Converts eager route components to loadComponent lazy loaders for code splitting. |
| apps/docs/src/app/config.ts | Wires in DocsTitleStrategy and analytics providers; updates router provider types. |
| apps/docs/src/app/components/welcome/welcome.component.ts | Enables OnPush for welcome page. |
| apps/docs/src/app/components/welcome/welcome.component.html | Migrates welcome text to centralized i18n (t(...)). |
| apps/docs/src/app/components/version-picker/version-picker.directive.ts | Adds error handling + teardown for version fetch request. |
| apps/docs/src/app/components/stackblitz/stackblitz-writer.ts | Evicts failed example promises from cache so retries work after errors. |
| apps/docs/src/app/components/stackblitz/stackblitz-button.ts | Migrates to signal inputs/computed; enables OnPush; simplifies state handling. |
| apps/docs/src/app/components/sidenav/sidenav.ts | Keeps selection in sync with router navigation; replaces setTimeout with afterNextRender. |
| apps/docs/src/app/components/sidenav/sidenav.spec.ts | Adds a unit test proving selected node tracks URL after navigation. |
| apps/docs/src/app/components/select-example/select-example.component.ts | Removes unused content string from example component. |
| apps/docs/src/app/components/page-not-found/page-not-found.component.ts | Migrates strings to centralized i18n (t(...)). |
| apps/docs/src/app/components/navbar/navbar.template.html | Adds null-guard for header text and migrates theme header to i18n. |
| apps/docs/src/app/components/navbar/navbar.component.ts | Enables OnPush; removes improper ThemeService.ngOnDestroy() call; marks for check on media query changes; uses central translations. |
| apps/docs/src/app/components/live-example/markdown-content.ts | Extracts shared markdown helpers (escape, error HTML, fragment rewrite, shared class constants). |
| apps/docs/src/app/components/live-example/docs-live-example.ts | Migrates to signal inputs/outputs, OnPush, shared markdown helpers, and safer DOM handling. |
| apps/docs/src/app/components/live-example-viewer/docs-live-example-viewer.ts | Enables OnPush; switches to viewChild; guards height calculation; marks for check after async file fetch. |
| apps/docs/src/app/components/live-example-viewer/docs-live-example-viewer.scss | Adds CSS var fallback for background token. |
| apps/docs/src/app/components/live-example-viewer/docs-live-example-viewer.html | Improves a11y for source toggle (role/tabindex/aria-expanded/space key) and migrates strings to i18n. |
| apps/docs/src/app/components/icons-viewer/icons-viewer.template.html | Migrates strings to i18n and improves icon grid keyboard/a11y behavior. |
| apps/docs/src/app/components/icons-viewer/icons-viewer.component.ts | Cleans up subscriptions and removes local title setting (now centralized). |
| apps/docs/src/app/components/icons-viewer/icon-preview-modal/icon-preview-modal.template.html | Migrates strings/tooltips to centralized i18n (t(...)). |
| apps/docs/src/app/components/icons-viewer/icon-preview-modal/icon-preview-modal.component.ts | Uses DocsClipboardService for copy+toast; removes duplicate clipboard/toast wiring. |
| apps/docs/src/app/components/footer/footer.component.html | Migrates footer strings to centralized i18n (t(...)). |
| apps/docs/src/app/components/example-viewer/example-viewer.ts | Migrates to signal inputs/outputs and shared markdown helpers; enables OnPush; uses observer-form subscribe. |
| apps/docs/src/app/components/example-viewer/example-viewer.spec.ts | Adds unit tests for fetch/no-fetch behavior when setting documentUrl. |
| apps/docs/src/app/components/design-tokens-viewers/typography-overview.ts | Enables OnPush and migrates strings/tooltips to centralized i18n. |
| apps/docs/src/app/components/design-tokens-viewers/tokens-overview.ts | Enables OnPush, replaces recursive template outlet with control flow, caches token reads per theme, replaces setTimeout with afterNextRender. |
| apps/docs/src/app/components/design-tokens-viewers/tokens-overview.spec.ts | Adds a perf characterization test asserting token reads are cached per theme. |
| apps/docs/src/app/components/design-tokens-viewers/design-tokens-viewer.ts | Migrates token viewer strings/links to centralized translations. |
| apps/docs/src/app/components/copy-button/copy-button.ts | Improves copy button a11y/keyboard support and migrates to DocsClipboardService + signals. |
| apps/docs/src/app/components/component-viewer/component-viewer.template.html | Migrates tab labels to centralized i18n. |
| apps/docs/src/app/components/component-viewer/component-viewer.component.ts | Removes per-view title setting; ensures early return after redirect when item missing. |
| apps/docs/src/app/components/component-viewer/component-viewer-wrapper.ts | Enables OnPush and migrates callout title to centralized i18n. |
| apps/docs/src/app/components/component-viewer/component-overview.template.html | Migrates callout title to centralized i18n. |
| apps/docs/src/app/components/code-snippet/code-snippet.ts | Uses DocsClipboardService instead of duplicating copy+toast behavior and locale branching. |
| apps/docs/src/app/components/anchors/anchors.component.ts | Enables OnPush; guards missing scroll container; shares markdown heading class mapping; removes NgClass usage. |
| apps/docs/src/app/components/anchors/anchors.component.spec.ts | Adds tests for scroll-container guard and shared heading class mapping. |
| apps/docs/src/app/components/anchors/anchors.component.html | Replaces ngClass with [class.foo] binding. |
| apps/docs/src/app/components/anchors/_anchors-theme.scss | Replaces magic numbers with CSS vars; removes legacy box-shadow mixin. |
| apps/docs/src/app/app.component.ts | Enables OnPush; makes isExamplesPage readonly. |
| angular.json | Removes docs environment fileReplacements from the production build configuration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- index.html: correct analytics provider name in comment (docsProvideAnalytics)
- markdown-content: guard sanitizer null result to avoid href=null
- docs-examples stub: resolve loadExample with {} so consumers don't crash
artembelik
approved these changes
Jul 10, 2026
NikGurev
reviewed
Jul 10, 2026
NikGurev
reviewed
Jul 10, 2026
NikGurev
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.