Skip to content

Fix 38 WCAG 2.1 AA accessibility violations on recharts.github.io#6559

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/fix-13690587-40345658-2f74751b-fb9f-4ccd-8eb1-51cf5db7577d
Closed

Fix 38 WCAG 2.1 AA accessibility violations on recharts.github.io#6559
Copilot wants to merge 2 commits intomainfrom
copilot/fix-13690587-40345658-2f74751b-fb9f-4ccd-8eb1-51cf5db7577d

Conversation

Copy link
Contributor

Copilot AI commented Nov 3, 2025

LambdaTest accessibility scan identified 38 violations on recharts.github.io: 29 serious color contrast issues, 8 moderate landmark issues, and 1 viewport zoom restriction.

Changes

Color contrast fixes (29 violations)

  • Updated brand colors to meet 4.5:1 ratio for normal text:
    • $brand-primary: #1281ca#1074b6 (5.01:1)
    • $brand-info: #22b5bf#18828a (4.57:1)
    • $gray-light: #999999#757575 (4.61:1)
  • Custom CodeMirror syntax theme with accessible token colors (#007070 for attributes, 5.57:1)

Semantic landmarks (8 violations)

  • Wrapped page content in <main> element in Frame.tsx

Viewport zoom (1 violation)

  • Changed maximum-scale=2maximum-scale=5 to allow 500% zoom

Screenshot

After fixes

Colors are slightly darker while preserving brand identity. All contrast ratios verified programmatically against WCAG 2.1 AA thresholds.

Original prompt

This section details on the original issue you should resolve

<issue_title>Accessibility problems on recharts.github.io</issue_title>
<issue_description>Test name: October 27, 1:22 PM, UTC
Test ID: SCHT_F5CCBEC7-B2F0-4245-BE25-66140763B54E
Test URL: https://accessibility.lambdatest.com/accessibility-scheduling/SCH_AAFQHCUG1L8O1AXNL1F3B/test/SCHT_F5CCBEC7-B2F0-4245-BE25-66140763B54E
Test Type: Scheduled
Total Issues: 38
Created at: 2025-10-27T13:22:32Z

Issue Severity:
Critical: 0
Serious: 29
Moderate: 8
Minor: 1
Needs_review: 0
Best_practices: 9

Configuration:
Auth added: No
Best practices: Yes
Needs review: Yes
Tunnel status: OFF
WCAG Version: WCAG 2.1 AA


Pages: 1
</issue_description>

Comments on the Issue (you are @copilot in this section)

@PavelVanecek [October 27, 1_22 PM, UTC.json](https://github.com/user-attachments/files/23303755/October.27.1_22.PM.UTC.json)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Summary by CodeRabbit

  • New Features

    • Enhanced code editor syntax highlighting with improved accessibility contrast and readability.
  • Style

    • Updated brand color palette for visual consistency.
    • Increased maximum zoom support from 2x to 5x for improved mobile accessibility.
    • Refined gray color tone for better design cohesion.
  • UI Improvements

    • Enhanced page layout with semantic content structure.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 3, 2025

Walkthrough

This PR improves website accessibility by adjusting viewport zoom capabilities, updating color palette for contrast compliance, wrapping main content in semantic HTML, and implementing a custom Lezer-based accessible syntax highlighting style for CodeMirror. Changes address accessibility audit findings.

Changes

Cohort / File(s) Summary
Viewport & Dependencies
www/index.html, www/package.json
Increased viewport maximum-scale from 2 to 5; added @lezer/highlight ^1.2.3 dependency
Semantic HTML
www/src/layouts/Frame.tsx
Wrapped children content in <main> semantic element
Color & Style Variables
www/src/styles/_variables.scss
Updated color palette: $gray-light to #757575, $brand-primary to #1074b6, $brand-info to #18828a; synchronized CSS custom properties in body selector
Syntax Highlighting
www/src/utils/CodeMirrorEditor.tsx
Replaced default CodeMirror highlighting with custom accessibleHighlightStyle using Lezer highlight tags for improved contrast and accessibility

Sequence Diagram

sequenceDiagram
    participant CodeMirror as CodeMirror Editor
    participant HighlightExt as Syntax Highlighting<br/>(syntaxHighlighting)
    participant AccessibleStyle as accessibleHighlightStyle<br/>(custom Lezer tags)
    participant LezerTags as Lezer Highlight Tags

    CodeMirror->>HighlightExt: Register extension
    HighlightExt->>AccessibleStyle: Initialize with custom style
    AccessibleStyle->>LezerTags: Map tokens to tags<br/>(improved contrast)
    LezerTags-->>AccessibleStyle: Apply color mappings
    AccessibleStyle-->>CodeMirror: Render highlighted code
    Note over CodeMirror,AccessibleStyle: NEW: Custom accessible colors<br/>instead of defaultHighlightStyle
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • The viewport and semantic HTML changes are straightforward edits with no logic impact
  • Color variable updates are direct substitutions but should be validated for visual consistency across the site
  • CodeMirror highlighting requires attention to ensure all syntax token types are properly covered by the new accessibleHighlightStyle mappings and contrast ratios are WCAG AA compliant

Possibly related PRs

Suggested reviewers

  • ckifer

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title 'Fix 38 WCAG 2.1 AA accessibility violations on recharts.github.io' is clear, specific, and directly related to the main changeset. It accurately describes the primary objective of addressing accessibility violations identified by the LambdaTest scan, matching the scope of changes across multiple files (color contrast fixes, semantic landmarks, and viewport zoom).
Description check ✅ Passed The pull request description is comprehensive and mostly complete. It includes a clear summary of the problem, categorized breakdown of fixes (color contrast, semantic landmarks, viewport zoom), specific color value changes with contrast ratios, and a screenshot. While the description doesn't strictly follow the provided template structure (missing explicit checklist items and testing details), the essential information is present and well-organized to explain the changes and their rationale.
Linked Issues check ✅ Passed The pull request directly addresses all primary coding objectives from linked issue #6558. The changes implement: (1) color contrast fixes updating $brand-primary, $brand-info, and $gray-light to meet 4.5:1 WCAG 2.1 AA ratios, (2) semantic landmark fixes by wrapping page content in a element, and (3) viewport zoom adjustment from maximum-scale=2 to 5. All 38 reported violations (29 serious, 8 moderate, 1 minor) are targeted through these modifications.
Out of Scope Changes check ✅ Passed All code changes are directly related to addressing the accessibility violations identified in issue #6558. The modifications to www/index.html (viewport zoom), www/src/styles/_variables.scss (color contrast), www/src/layouts/Frame.tsx (semantic landmarks), www/src/utils/CodeMirrorEditor.tsx (syntax highlighting accessibility), and www/package.json (adding @lezer/highlight dependency) are all necessary components of the accessibility fix. No extraneous or unrelated changes are present.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch copilot/fix-13690587-40345658-2f74751b-fb9f-4ccd-8eb1-51cf5db7577d

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a73aa5 and f3f2696.

⛔ Files ignored due to path filters (1)
  • www/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • www/index.html (1 hunks)
  • www/package.json (1 hunks)
  • www/src/layouts/Frame.tsx (1 hunks)
  • www/src/styles/_variables.scss (1 hunks)
  • www/src/utils/CodeMirrorEditor.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
www/**

📄 CodeRabbit inference engine (DEVELOPING.md)

Use the www directory to add and commit examples for the documentation website (recharts.github.io)

Files:

  • www/package.json
  • www/src/layouts/Frame.tsx
  • www/src/styles/_variables.scss
  • www/src/utils/CodeMirrorEditor.tsx
  • www/index.html
🧠 Learnings (1)
📚 Learning: 2025-10-25T07:36:02.229Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-25T07:36:02.229Z
Learning: Recharts aims for simple, declarative, and composable charts; prioritize consistency, usability, performance, and accessibility

Applied to files:

  • www/index.html
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Visual Regression Tests
🔇 Additional comments (6)
www/index.html (1)

7-7: LGTM! Enhanced zoom capability improves accessibility.

Increasing maximum-scale from 2 to 5 allows users to zoom up to 500%, exceeding WCAG 2.1 AA requirements (200% minimum) and providing better accessibility for users with low vision.

www/package.json (1)

44-44: LGTM! Dependency supports accessible syntax highlighting.

The @lezer/highlight library is correctly added to support the new accessible CodeMirror highlight style introduced in CodeMirrorEditor.tsx.

www/src/layouts/Frame.tsx (1)

30-30: LGTM! Semantic landmark improves accessibility.

Wrapping the page content in a <main> element provides a proper semantic landmark for screen readers and assistive technologies, addressing the reported semantic structure violations.

www/src/utils/CodeMirrorEditor.tsx (2)

118-118: LGTM! Correctly applies the accessible highlight style.

The syntax highlighting is properly configured to use the new accessible highlight style instead of the default.


17-40: All color contrast ratios meet WCAG 2.1 AA requirements.

Verification confirms that all 14 color tokens in accessibleHighlightStyle meet or exceed the 4.5:1 contrast ratio requirement against a white background. The lowest ratio is meta/comment at 4.82:1, and the highest is definition at 14.65:1. The specific fix documented at line 39 (attributeName changed to #7070) meets requirements with a 5.91:1 ratio.

www/src/styles/_variables.scss (1)

16-16: All brand colors meet WCAG 2.1 AA contrast requirements.

Verification confirms the updated colors meet the required 4.5:1 contrast ratio against white background:

  • $brand-primary: 5.01:1 ✓
  • $brand-info: 4.57:1 ✓
  • $gray-light: 4.61:1 ✓

No further changes needed.


Comment @coderabbitai help to get the list of available commands and usage tips.

Co-authored-by: PavelVanecek <1100170+PavelVanecek@users.noreply.github.com>
Copilot AI changed the title [WIP] Accessibility problems on recharts.github.io Fix 38 WCAG 2.1 AA accessibility violations on recharts.github.io Nov 3, 2025
Copilot AI requested a review from PavelVanecek November 3, 2025 14:39
@codecov
Copy link

codecov bot commented Nov 3, 2025

Bundle Report

Bundle size has no change ✅

@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

❌ Patch coverage is 92.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.27%. Comparing base (2a73aa5) to head (f3f2696).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
www/src/layouts/Frame.tsx 0.00% 1 Missing ⚠️
www/src/utils/CodeMirrorEditor.tsx 95.83% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6559   +/-   ##
=======================================
  Coverage   91.27%   91.27%           
=======================================
  Files         489      489           
  Lines       40848    40871   +23     
  Branches     4570     4570           
=======================================
+ Hits        37282    37305   +23     
  Misses       3550     3550           
  Partials       16       16           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@PavelVanecek
Copy link
Collaborator

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 3, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

"@codemirror/language": "^6.11.3",
"@codemirror/state": "^6.5.2",
"@codemirror/view": "^6.38.6",
"@lezer/highlight": "^1.2.3",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look used, what is it used for?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know it's a peer dependency of codemirror. The AI put it in the previous PR as well and I removed it.

@codepilot why is this new dependency added? Do we import and use directly somewhere?

@PavelVanecek
Copy link
Collaborator

I'm remaking the styles a bit so I will include these changes in my other PR.

foldService,
foldEffect,
} from '@codemirror/language';
import { tags as t } from '@lezer/highlight';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha it's used here.

Also it's a peer dependency of codemirror anyway so it comes included:

npm why @lezer/highlight          
@lezer/highlight@1.2.3
node_modules/@lezer/highlight
  @lezer/highlight@"^1.0.0" from @codemirror/language@6.11.3
  node_modules/@codemirror/language
    @codemirror/language@"^6.11.3" from the root project
    @codemirror/language@"^6.0.0" from @codemirror/autocomplete@6.19.1
    node_modules/@codemirror/autocomplete
      @codemirror/autocomplete@"^6.0.0" from @codemirror/lang-javascript@6.2.4
      node_modules/@codemirror/lang-javascript
        @codemirror/lang-javascript@"^6.2.4" from the root project
    @codemirror/language@"^6.0.0" from @codemirror/commands@6.10.0
    node_modules/@codemirror/commands
      @codemirror/commands@"^6.10.0" from the root project
    @codemirror/language@"^6.6.0" from @codemirror/lang-javascript@6.2.4
    node_modules/@codemirror/lang-javascript
      @codemirror/lang-javascript@"^6.2.4" from the root project
  @lezer/highlight@"^1.1.3" from @lezer/javascript@1.5.4
  node_modules/@lezer/javascript
    @lezer/javascript@"^1.0.0" from @codemirror/lang-javascript@6.2.4
    node_modules/@codemirror/lang-javascript
      @codemirror/lang-javascript@"^6.2.4" from the root project

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.

Accessibility problems on recharts.github.io

3 participants