Skip to content

Commit 26a517c

Browse files
bloveclaude
andauthored
fix(cockpit-render): no [object Object] flash for unresolved value bindings mid-stream (#773)
demo-value / demo-label rendered their value input directly ({{ value() }}). During streaming, a partial $computed binding resolves to an object, so the row briefly showed 'LABEL: [object Object]' between the skeleton and the final value. Route the value through toDisplayText() via a displayValue computed and guard the row on it, so an unresolved object renders nothing (not [object Object]) until it resolves. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 4fbca04 commit 26a517c

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

cockpit/render/computed-functions/angular/src/app/computed-functions.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ import { toDisplayText } from '../../../../shared/to-display-text';
3535
}
3636
`,
3737
template: `
38-
@if (label() || value()) {
38+
@if (displayValue()) {
3939
<div class="row">
4040
<span class="row__label">{{ label() }}:</span>
41-
<span class="row__value">{{ value() }}</span>
41+
<span class="row__value">{{ displayValue() }}</span>
4242
</div>
4343
} @else if (loading()) {
4444
<div class="sr-skeleton" style="height: 11px; width: 100%; margin: 3px 0;"></div>
@@ -49,6 +49,9 @@ import { toDisplayText } from '../../../../shared/to-display-text';
4949
class DemoValueComponent {
5050
readonly label = input('');
5151
readonly value = input<unknown>('');
52+
// Coerce through toDisplayText so an unresolved binding object mid-stream
53+
// (e.g. a partial `$computed` value) renders as the skeleton, not `[object Object]`.
54+
readonly displayValue = computed(() => toDisplayText(this.value()));
5255
readonly childKeys = input<string[]>([]);
5356
readonly spec = input<Spec | null>(null);
5457
readonly bindings = input<Record<string, string>>({});

cockpit/render/state-management/angular/src/app/state-management.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ class DemoHeadingComponent {
8383
}
8484
`,
8585
template: `
86-
@if (label() || value()) {
86+
@if (displayValue()) {
8787
<div class="row">
8888
<span class="row__label">{{ label() }}:</span>
89-
<span class="row__value">{{ value() }}</span>
89+
<span class="row__value">{{ displayValue() }}</span>
9090
</div>
9191
} @else if (loading()) {
9292
<div class="sr-skeleton" style="height: 11px; width: 100%; margin: 3px 0;"></div>
@@ -97,6 +97,7 @@ class DemoHeadingComponent {
9797
class DemoLabelComponent {
9898
readonly label = input('');
9999
readonly value = input('');
100+
readonly displayValue = computed(() => toDisplayText(this.value()));
100101
readonly childKeys = input<string[]>([]);
101102
readonly spec = input<Spec | null>(null);
102103
readonly bindings = input<Record<string, string>>({});

0 commit comments

Comments
 (0)