From 31a308416b089ad04a94c57fbf93cb09cf29bde7 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Mon, 30 Mar 2026 20:17:40 +0200 Subject: [PATCH] Various improvements --- libs/ui/src/lib/value/value.component.stories.ts | 6 +++--- libs/ui/src/lib/value/value.component.ts | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/libs/ui/src/lib/value/value.component.stories.ts b/libs/ui/src/lib/value/value.component.stories.ts index 0fb6276a6..214331efc 100644 --- a/libs/ui/src/lib/value/value.component.stories.ts +++ b/libs/ui/src/lib/value/value.component.stories.ts @@ -14,13 +14,13 @@ export default { }) ], argTypes: { - enableCopyToClipboardButton: { - control: 'boolean' - }, deviceType: { control: 'select', options: ['desktop', 'mobile'] }, + enableCopyToClipboardButton: { + control: 'boolean' + }, size: { control: 'select', options: ['small', 'medium', 'large'] diff --git a/libs/ui/src/lib/value/value.component.ts b/libs/ui/src/lib/value/value.component.ts index c5e00b0cd..9c3330466 100644 --- a/libs/ui/src/lib/value/value.component.ts +++ b/libs/ui/src/lib/value/value.component.ts @@ -5,6 +5,7 @@ import { CommonModule } from '@angular/common'; import { AfterViewInit, ChangeDetectionStrategy, + ChangeDetectorRef, Component, computed, CUSTOM_ELEMENTS_SCHEMA, @@ -47,7 +48,8 @@ export class GfValueComponent implements AfterViewInit, OnChanges { @Input() unit = ''; @Input() value: number | string = ''; - @ViewChild('labelContent', { static: false }) labelContent!: ElementRef; + @ViewChild('labelContent', { static: false }) + labelContent!: ElementRef; public absoluteValue = 0; public formattedValue = ''; @@ -57,6 +59,7 @@ export class GfValueComponent implements AfterViewInit, OnChanges { public useAbsoluteValue = false; public constructor( + private changeDetectorRef: ChangeDetectorRef, private clipboard: Clipboard, private snackBar: MatSnackBar ) { @@ -82,8 +85,14 @@ export class GfValueComponent implements AfterViewInit, OnChanges { } public ngAfterViewInit() { - const el = this.labelContent.nativeElement; - this.hasLabel = el.textContent.trim().length > 0 || el.children.length > 0; + if (this.labelContent) { + const element = this.labelContent.nativeElement; + + this.hasLabel = + element.children.length > 0 || element.textContent.trim().length > 0; + + this.changeDetectorRef.markForCheck(); + } } public ngOnChanges() {