Skip to content

fix: thread format/asset/locale into StatCard's sparkline - #743

Open
smartcalsystems-sketch wants to merge 1 commit into
MergeFi:mainfrom
smartcalsystems-sketch:fix-statcard-sparkline-formatvalue-709
Open

smartcalsystems-sketch wants to merge 1 commit into
MergeFi:mainfrom
smartcalsystems-sketch:fix-statcard-sparkline-formatvalue-709

Conversation

@smartcalsystems-sketch

Copy link
Copy Markdown

Problem

StatCard renders <Sparkline data={sparkline} label={label} /> without formatValue, so describeTrend uses String(v). A "Lifetime earnings" card is announced as "trending up from 1234.5 to 8420", with no currency or locale grouping, while the visible value is "$8,420.00".

Fix

Passes formatValue={(v) => formatValue(v, format, asset, locale).display} to Sparkline — reusing the exact same formatter (and the exact format/asset/locale props) StatCard already applies to its own headline value, so the sparkline's spoken description can never disagree with what's on screen. format="raw" cards are unaffected, since formatValue's "raw" case is already String(v) — identical to the previous default.

Testing

  • Added a test for a format="currency" card asserting the sparkline's accessible name now reads "trending up from 1,234.5 USDC to 8,420 USDC" instead of raw numbers.
  • Full StatCard.test.tsx: 24/24 passing (23 pre-existing + 1 new), including the existing raw-format sparkline-naming test unchanged.
  • tsc --noEmit and eslint clean on both changed files (one pre-existing, unrelated isRTLLocale unused-import warning confirmed present on main before this change too).

Closes #709

…geFi#709)

StatCard rendered <Sparkline data={sparkline} label={label} /> without
formatValue, so describeTrend fell back to String(v). A 'Lifetime
earnings' card was announced as 'trending up from 1234.5 to 8420', with
no currency symbol or locale grouping, while the visible value right
next to it read '$8,420.00'.

Pass formatValue={(v) => formatValue(v, format, asset, locale).display}
-- reusing the same formatter StatCard already applies to its own
headline value -- so the sparkline's accessible description agrees with
what's on screen. format='raw' cards are unaffected: formatValue's raw
case is already String(v), identical to the previous default.
@vercel

vercel Bot commented Oct 13, 2026

Copy link
Copy Markdown

@smartcalsystems-sketch is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StatCard's sparkline announces raw numbers (e.g. '1234.5') for currency cards

1 participant