Skip to content

Conversation

@arbirali
Copy link

📄 Description

This PR enhances the accessibility of the theme toggle switch in the shared header component by improving how it is announced to screen readers. This update ensures users who rely on assistive technologies can understand the purpose of the toggle and interact with it effectively.

The change aligns with WCAG Success Criterion 4.1.2 – Name, Role, Value, which requires that user interface elements expose meaningful names and roles programmatically.


🎯 Issue

  • Actual Result:
    The theme toggle (used to switch between light and dark modes) did not have an accessible name. As a result, screen readers could not interpret or announce its function, making it difficult for visually impaired users to understand its purpose.

  • Expected Behaviour:
    The toggle should expose a descriptive label to screen readers that clearly communicates its action — for example, “Switch to dark theme.”


✅ Fix

  • Improved screen reader accessibility by programmatically exposing a meaningful name for the theme toggle control.

🔗 Related

@codecov
Copy link

codecov bot commented May 14, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 68.45%. Comparing base (6b98d10) to head (89ed493).
Report is 2 commits behind head on sumac/indigo.

Files with missing lines Patch % Lines
src/ThemeToggleButton.jsx 75.00% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           sumac/indigo      #29      +/-   ##
================================================
+ Coverage         68.39%   68.45%   +0.05%     
================================================
  Files                49       49              
  Lines               481      485       +4     
  Branches            107      107              
================================================
+ Hits                329      332       +3     
- Misses              149      150       +1     
  Partials              3        3              

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@wittjeff wittjeff left a comment

Choose a reason for hiding this comment

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

looks good to me

const themeCookieExpiry = 90; // days

const ThemeToggleButton = ({ intl }) => {
const [isDarkThemeEnabled, setIsDarkThemeEnabled] = useState(false);

Choose a reason for hiding this comment

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

Why is there a need for a state? This file already uses themeCookie/cookie to manage the dark theme toggle across sessions. Can't the same be followed for a11y?

Copy link
Author

Choose a reason for hiding this comment

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

@DawoudSheraz The state ensures the UI updates immediately when toggled, while the cookie handles persistence. Without state, the toggle’s visual feedback and screen reader announcements wouldn’t sync until a page reload, hurting both UX and accessibility.

@DawoudSheraz DawoudSheraz requested a review from ahmed-arb June 11, 2025 10:20
@arbirali arbirali merged commit 86a058a into edly-io:sumac/indigo Jun 11, 2025
6 checks passed
DawoudSheraz added a commit that referenced this pull request Jun 24, 2025
* fix: Add visible titles to image-based links
* feat: enhance accessibility by adding descriptive label to theme toggle (#29)
* feat: Header - Focus order meaning - Open Edx Demo Course (#30)
* feat: Header - Focus order meaning - Open Edx Demo Course
* refactor: unify responsive rendering using the existing Responsive component

Co-authored-by: Rahat Ali <rahat.ali@arbisoft.com>
Co-authored-by: hinakhadim <hina.khadim@arbisoft.com>
ahmed-arb pushed a commit that referenced this pull request Jul 8, 2025
* fix: Add visible titles to image-based links
* feat: enhance accessibility by adding descriptive label to theme toggle (#29)
* feat: Header - Focus order meaning - Open Edx Demo Course (#30)
* feat: Header - Focus order meaning - Open Edx Demo Course
* refactor: unify responsive rendering using the existing Responsive component

Co-authored-by: Rahat Ali <rahat.ali@arbisoft.com>
Co-authored-by: hinakhadim <hina.khadim@arbisoft.com>
ahmed-arb pushed a commit that referenced this pull request Jul 11, 2025
* fix: Add visible titles to image-based links
* feat: enhance accessibility by adding descriptive label to theme toggle (#29)
* feat: Header - Focus order meaning - Open Edx Demo Course (#30)
* feat: Header - Focus order meaning - Open Edx Demo Course
* refactor: unify responsive rendering using the existing Responsive component

Co-authored-by: Rahat Ali <rahat.ali@arbisoft.com>
Co-authored-by: hinakhadim <hina.khadim@arbisoft.com>
ahmed-arb pushed a commit that referenced this pull request Jul 16, 2025
* fix: Add visible titles to image-based links
* feat: enhance accessibility by adding descriptive label to theme toggle (#29)
* feat: Header - Focus order meaning - Open Edx Demo Course (#30)
* feat: Header - Focus order meaning - Open Edx Demo Course
* refactor: unify responsive rendering using the existing Responsive component

Co-authored-by: Rahat Ali <rahat.ali@arbisoft.com>
Co-authored-by: hinakhadim <hina.khadim@arbisoft.com>
ahmed-arb pushed a commit that referenced this pull request Jul 16, 2025
* fix: Add visible titles to image-based links
* feat: enhance accessibility by adding descriptive label to theme toggle (#29)
* feat: Header - Focus order meaning - Open Edx Demo Course (#30)
* feat: Header - Focus order meaning - Open Edx Demo Course
* refactor: unify responsive rendering using the existing Responsive component

Co-authored-by: Rahat Ali <rahat.ali@arbisoft.com>
Co-authored-by: hinakhadim <hina.khadim@arbisoft.com>
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.

3 participants