Skip to content

Numeric widget: toggling Show Background Graph does nothing until the widget is rebuilt #594

Description

@mairas

Symptom

Toggling Show Background Graph on a placed Numeric widget does nothing until the widget is rebuilt. Enabling it does not make the mini graph appear; disabling it does not remove one that is already running. Reloading the page shows the setting applied, so the stored config is correct — only the live update is missing.

Mechanism

showMiniChart is a signal that the template gates on (widget-numeric.component.html:1). It is written in exactly three places (widget-numeric.component.ts):

  • line 145, once during construction;
  • line 239, in ngOnInit, only when no stream is registered yet;
  • line 179, inside the subscription effect — and only past its early return.

That early return is the problem. The effect reads subscriptionSignature() (line 98), which is built from the path, path type, update interval, unit, source and the bootstrap-null flag. showMiniChart is not in it, so toggling only that option leaves the signature unchanged, the guard at line 163 returns, and the signal keeps its old value.

WidgetHost2Component.applyRuntimeConfig (the path the options dialog uses) updates the runtime options in place rather than recreating the component, so nothing else re-reads the flag.

The second effect at line 184 does re-run — it reads runtime.options() — but it early-returns on the same stale signal (if (!show) return;), so it cannot repair the state either. While there, note that miniGraphSignature is joined with '|' and is therefore always a non-empty string, making the if (!miniGraphSignature) return; guard on line 202 dead code.

Fix direction

Set showMiniChart from a dedicated effect that reads runtime.options()?.showMiniChart directly, instead of from inside the subscription effect. Write a failing test first: reconfigure a mounted Numeric widget with showMiniChart flipped and assert the <minigraph> element appears and disappears.

Provenance

Pre-existing on main; the code at lines 158-181 is identical there. Found by CodeRabbit on #593, which renamed updateMiniChartVisibility to updateMiniGraphVisibility and so touched those lines. Kept out of that PR because it is a behavior change in a rename-only PR and needs its own reproducing test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions