fix(ui): make the sparkline hover-tooltip keyboard-operable#4953
fix(ui): make the sparkline hover-tooltip keyboard-operable#4953philluiz2323 wants to merge 1 commit into
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4953 +/- ##
=======================================
Coverage 97.93% 97.93%
=======================================
Files 163 163
Lines 19389 19389
Branches 7364 7364
=======================================
Hits 18989 18989
Misses 53 53
Partials 347 347 🚀 New features to boost your workflow:
|
|
Caution 🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 🛑 Gittensory review result - fixes requiredReview updated: 2026-07-12 14:01:31 UTC
🛑 Suggested Action - Fix Blockers
Review summary Nits — 2 non-blocking
CI checks failing
Review context
Contributor next steps
Signal definitions
[BETA] Chat with GittensoryAsk Gittensory a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands Visual preview
Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
|
Gittensory is closing this pull request on the maintainer's behalf (CI is failing (checks, ui)). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed. |
Closes #3954
What
The shared
Sparklinecomponent (nowpackages/ui-kit/src/components/metagraphed/charts/sparkline.tsx, migrated there fromapps/ui/src/components/metagraphed/charts/sparkline.tsxsince this issue was filed) drove its per-point value/date tooltip purely fromonPointerMove/onPointerLeave. There was notabIndex,onFocus, oronKeyDownhandling, so keyboard-only and screen-reader users got only the single staticaria-labelsummary on the<svg>and never the point-by-point detail mouse users see on hover. This component is reused broadly (concentration-panel.tsx,subnet-history-chart.tsx,neuron-history-chart.tsx, and more).Changes
packages/ui-kit/src/components/metagraphed/charts/sparkline.tsx:<div>now getstabIndex={0}whenevercanTooltipis true (same gate the pointer-hover path already uses:interactive && pts.length > 1).onKeyDownhandlesArrowRight/ArrowLeftto step the samehoverindex state the pointer path already drives — so the existing tooltip/dot/guide-line rendering just works for keyboard focus too, with zero duplicated rendering logic.onFocusseedshoverto0(first point) so keyboard users get immediate feedback on focus, matching the "step through points" requirement;onBlurclears it, mirroringonPointerLeave.aria-live="polite"visually-hidden (sr-only) span mirroring the sametooltipTextused by the visual tooltip, so screen readers announce each point's value/date as the user arrows through — the issue's suggested mechanism.aria-label(only set whencanTooltip) now reads"{ariaLabel ?? "Sparkline chart"}, use arrow keys to step through values"— falling back to a generic label for the several real consumers (e.g.subnet-history-chart.tsx) that don't pass an explicitariaLabelprop, so the focusable element never ships without an accessible name.packages/ui-kit/dist/index.js/dist/index.cjsare regenerated (npm run build --workspace=packages/ui-kit) and committed alongside, per this package's own.gitignoreconvention —apps/uiconsumes it as a live workspace link, not a rebuilt-at-deploy artifact.Verification across real consumers
Verified interactively (Playwright) against two independent real consumers, not just in isolation:
concentration-panel.tsx's reward-driftDriftRowchart (Rewards tab,/subnets/$netuid): focusing the chart announces the first point's value via thearia-liveregion; steppingArrowRightthrough a real 32-point series correctly advances the announced/tooltip value once the underlying data changes (confirmed the value holds flat across a flat data segment, then updates exactly where the real series changes) — proving the index-stepping logic tracks real data, not just re-rendering a static string.subnet-history-chart.tsx's per-metric trend rows (Overview tab): confirmed a second, independently-renderedSparklineinstance (differentariaLabel) is likewise focusable and keyboard-steppable.Tabfrom a focused sparkline moves to the next natural focusable element with no trapping, and mouse-hover behavior (onPointerMove/onPointerLeave) is untouched — same code paths, now also driven by keyboard.On screenshots
This is a purely interaction-only fix — the sparkline's at-rest (unfocused, non-hovered) rendering is pixel-identical before and after; the only behavior change is what happens when a keyboard user focuses/steps through it, which a static image can't show. Per the repo's screenshot-contract guidance, skipping the static viewport×theme matrix for this reason and providing only the required animated evidence below.
Keyboard interaction (animated)
/subnets/19?tab=metagraph(Rewards)(GitHub doesn't inline-render
.webmfrom araw.githubusercontent.comlink in a PR body — click through to view. Before: repeatedly pressing Tab near the chart never reaches or steps through it — only the static SVG summary exists. After: focusing the chart directly and pressingArrowRightrepeatedly visibly moves the guide-line/dot and updates the tooltip through the real series.)Acceptance criteria
sparkline.tsxappears in the diffaria-live) as they doconcentration-panel.tsxandsubnet-history-chart.tsx), not just in isolationTesting
npm run build --workspace=packages/ui-kit+npm run typecheck --workspace=packages/ui-kit: clean.npx eslinton the changed source file: clean aside from pre-existing CRLF noise unrelated to this change.