Skip to content

fix(topics): KPI card shows a bare "0pts" delta when the change is 0 #360

Closed

Description

@gkhngyk

Problem

On the topic detail page (/dashboard/topics/[id]), the KPI cards at the top show a small change/delta next to the value. When the delta is exactly 0, the card renders a bare 0pts (e.g. the Positive sentiment card when it's at 0%). A zero change with no up/down arrow and no sign is meaningless noise — it should not be shown at all.

Root cause (from the code)

In the KpiCard component in web/src/app/[locale]/(dashboard)/dashboard/topics/[id]/page.tsx, the delta is rendered whenever it's not null/undefined:

{change !== null && change !== undefined && (
  <span ...>
    {change > 0 ? <TrendingUp/> : change < 0 ? <TrendingDown/> : null}
    {change > 0 ? '+' : ''}
    {change}
    {suffix === '%' ? 'pts' : ''}
  </span>
)}

When change === 0: no arrow (both > 0 and < 0 are false), no + sign, and it prints 0 — plus pts for %-suffixed cards — so you get 0pts (or a bare 0 on the count cards). This affects all four cards (Avg visibility, Brand mentions, Citations, Positive sentiment), but it's most visible on Positive sentiment when the value is 0%.

Proposed change

Treat a zero delta the same as "no delta" — don't render the change span when change === 0:

{change !== null && change !== undefined && change !== 0 && (
  ...
)}

That hides 0pts / 0 across all the KPI cards. (Alternative, if we'd rather still signal "no change": render a neutral — instead of the number — but hiding it is simpler and matches the ask.)

How to test

  1. Open a topic whose Positive sentiment is 0% → the card shows just 0% with no 0pts delta next to it.
  2. A non-zero change still renders normally (e.g. +5pts in green, -3pts in red, with the arrow).
  3. The same holds for the other KPI cards when their change is 0 (no bare 0).

Notes

  • Small, self-contained UI change — good first issue.
  • The Insights and prompt detail pages have similar KPI-card delta logic; out of scope here, but worth a glance as a follow-up if the same 0 shows there.

Activity

  1. added
    bug
    good first issue
    help wanted
    on Jul 7, 2026
  2. prakashiitp commented on Jul 7, 2026

    @prakashiitp
    Contributor

    Hi @gkhngyk, I'd like to work on this issue. Could you please assign it to me? Thanks!

  3. gkhngyk commented on Jul 7, 2026

    @gkhngyk
    ContributorAuthor

    Thanks @prakashiitp — assigned to you! 🎉 The fix is in the KpiCard component in topics/[id]/page.tsx: the delta renders whenever change !== null && change !== undefined, so a zero change prints a bare 0pts (or 0). Add && change !== 0 to that guard so a zero delta isn't shown. Non-zero deltas (e.g. +5pts / -3pts with the arrow) should still render as before. Ping here if anything's unclear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

buggood first issuehelp wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions