fix: update hover text colors for Project Funding data viz#5915
fix: update hover text colors for Project Funding data viz#5915weimiao67 wants to merge 7 commits into
Conversation
josbell
left a comment
There was a problem hiding this comment.
Blocking: WCAG AA contrast failures on interactive hover elements
This PR's stated goal is fixing text colors, but it introduces two confirmed WCAG AA failures on the active hover state. Given this is a government application with Section 508 obligations, these need to be resolved before merge. Recommend looping in the design team — the color assignments for HMRF and OTIP may need to be revisited in Figma as well.
🔴 Required fixes
1. OTIP is miscategorized as a light background
--portfolio-bar-graph-otip: #1975aa is a medium-dark blue. Including it in LIGHT_BACKGROUND_PORTFOLIOS assigns dark text (#1B1B1B) to the hover tag, which yields a 3.42:1 contrast ratio — fails WCAG AA (minimum 4.5:1). White text would pass at 5.04:1.
Fix: remove "OTIP" from LIGHT_BACKGROUND_PORTFOLIOS.
2. HMRF hover text regresses to a WCAG AA failure
HMRF is intentionally excluded from LIGHT_BACKGROUND_PORTFOLIOS (gets white text on hover). --portfolio-bar-graph-hmrf: #428cae with white text yields 3.75:1 — fails WCAG AA. Dark text would pass at 4.59:1. The previous behavior (dark text) was actually more accessible.
Fix: add "HMRF" to LIGHT_BACKGROUND_PORTFOLIOS. This overrides the current "design intent" of white-on-HMRF — please flag this to the design team so Figma can be updated to match.
🟡 Should fix (touches code changed in this PR)
3. No active-state test coverage in ProjectFundingByPortfolioCard
The HorizontalStackedBar mock only destructures { data } — setActiveId is never called, so isActive is always false in every test. The activeTextColor logic added by this PR (ProjectFundingByPortfolioCard.jsx line ~61) has zero test coverage. PortfolioLegend has equivalent active-state tests — this component should too.
4. fontWeight: "bold" vs fake-bold inconsistency in PortfolioLegend
The active percent <Tag> uses inline fontWeight: "bold", while the adjacent abbreviation and currency spans use the fake-bold CSS class (text-shadow, avoids layout shift). ProjectFundingByPortfolioCard uses fake-bold for the same element. Replace fontWeight: "bold" with fake-bold for consistency.
⚪ Optional
5. "DD" vs "DO" in LIGHT_BACKGROUND_PORTFOLIOS — "DO" is the primary abbreviation, "DD" is the alias. The alias-aware lookup makes it work correctly, but using the primary abbreviation would be consistent with every other entry in the list.
…ngByPortfolioCard
|
@josbell Thanks for the thorough review — all five points were valid. I verified the two contrast failures by computing the WCAG ratios directly and confirmed the missing test coverage. All addressed: 🔴 Required fixes
🟡 Should fix
⚪ Optional
All unit tests pass and lint/format are clean. |
What changed
Fixes hover-interaction color issues on the Project Funding tab and aligns the Project Funding by Portfolio viz with the All Portfolios page.
text-ink) for readability against the cyan carry-forward background (#009ec1). (Tag.jsx)buildPortfolioChartDatapreviously assigned bar colors sequentially by position, so a given portfolio (e.g. HMRF) could get a different color depending on how many portfolios were present. It now assigns each portfolio its fixed color by abbreviation (resolving aliases likeDD→DO), identical totransformPortfoliosToChartData. A portfolio now always renders the same color across both views.getActivePortfolioTagTextColor/LIGHT_BACKGROUND_PORTFOLIOSintoPortfolioSummaryCards.helpers.js. BothPortfolioLegend(All Portfolios) andProjectFundingByPortfolioCardnow use this single source of truth, so their hover effects (background + text color) stay identical and can't drift apart.LIGHT_BACKGROUND_PORTFOLIOS, so its active percentage tag shows white text on both the Project Funding by Portfolio viz and the All Portfolios page.Issue
#668 (comment)
How to test
/portfolios) and hover over the legend — verify the hover effect (background + text color) matches the Project Funding by Portfolio viz, including HMRF showing white text.A11y impact
Storybook
Definition of Done Checklist