From 59712a2988a2c7db699d86c901e6b9f3ac48b6a9 Mon Sep 17 00:00:00 2001 From: Maksim Ivanov Date: Wed, 28 Aug 2024 18:32:04 +0300 Subject: [PATCH] fix(addon-doc): code glitch in ssr (#8705) --- projects/addon-doc/components/code/index.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/projects/addon-doc/components/code/index.ts b/projects/addon-doc/components/code/index.ts index b6d19ccbd773..08d0c7de853a 100644 --- a/projects/addon-doc/components/code/index.ts +++ b/projects/addon-doc/components/code/index.ts @@ -1,6 +1,12 @@ import {ClipboardModule} from '@angular/cdk/clipboard'; -import {AsyncPipe, NgForOf, NgIf} from '@angular/common'; -import {ChangeDetectionStrategy, Component, inject, Input} from '@angular/core'; +import {AsyncPipe, isPlatformServer, NgForOf, NgIf} from '@angular/common'; +import { + ChangeDetectionStrategy, + Component, + inject, + Input, + PLATFORM_ID, +} from '@angular/core'; import {toSignal} from '@angular/core/rxjs-interop'; import { TUI_DOC_EXAMPLE_MARKDOWN_CODE_PROCESSOR, @@ -21,6 +27,7 @@ import {BehaviorSubject, map, startWith, Subject, switchMap, timer} from 'rxjs'; styleUrls: ['./index.less'], changeDetection: ChangeDetectionStrategy.OnPush, host: { + '[style.visibility]': 'isServer ? "hidden" : "visible"', '[class._has-filename]': 'hasFilename', }, }) @@ -28,6 +35,8 @@ export class TuiDocCode { private readonly icons = inject(TUI_DOC_ICONS); private readonly rawLoader$$ = new BehaviorSubject(''); + protected readonly isServer = isPlatformServer(inject(PLATFORM_ID)); + protected readonly markdownCodeProcessor = inject>( TUI_DOC_EXAMPLE_MARKDOWN_CODE_PROCESSOR, );