fix(a11y): topbar logo and dark-mode toggle visible in HCM#10847
Open
bmatar wants to merge 1 commit intoswagger-api:masterfrom
Open
fix(a11y): topbar logo and dark-mode toggle visible in HCM#10847bmatar wants to merge 1 commit intoswagger-api:masterfrom
bmatar wants to merge 1 commit intoswagger-api:masterfrom
Conversation
In Windows High Contrast Mode the standalone topbar Swagger logo and the dark-mode toggle's lightbulb icon both become invisible or near- invisible against the HCM-substituted Canvas. The logo's wordmark paths use literal fill #fff which preserves under Chromium's default forced-color-adjust: preserve-parent-color for SVG and disappears in HCM light. The dark-mode toggle's SVG fill #e4e6e6 likewise preserves and renders at low contrast in any HCM theme; the parent .dark-mode- toggle also has opacity: 0.8, which composites multiplicatively and dims the icon further. A new @media (forced-colors: active) block in _topbar.scss pins the logo wordmark paths to CanvasText and the dark-mode toggle SVG to ButtonText with forced-color-adjust: none, and resets the parent opacity to 1 so the system-color contrast guarantee isn't dimmed. ButtonText/CanvasText are the system colors paired with ButtonFace/ Canvas and guarantee contrast in any user HCM theme. Refs swagger-api#7350
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In Windows High Contrast Mode (Edge / Chromium with
forced-colors: active), the standalone topbar's Swagger logo wordmark and the dark-mode toggle's lightbulb icon both become invisible or near-invisible against the HCM-substituted Canvas. The logo wordmark paths use literalfill="#fff", and the dark-mode toggle SVG usesfill: #e4e6e6— both preserved by Chromium's spec-correct defaultforced-color-adjust: preserve-parent-colorfor SVG. The dark-mode toggle wrapper also hasopacity: 0.8, which composites multiplicatively and dims the icon further regardless of the path fill.In HCM-light, the white logo wordmark is invisible on Canvas-white. In HCM-dark, the gray lightbulb sits at low contrast. The toggle button is operable (it has a focusable
<button>) but sighted HCM users have no visible cue.A new
@media (forced-colors: active)block in_topbar.scsspins the logo wordmark paths toCanvasTextand the dark-mode toggle SVG toButtonText, both withforced-color-adjust: none, and resets the wrapper opacity to 1 so the system-color contrast guarantee isn't dimmed.Motivation and Context
Part of the HCM accessibility backlog tracked in #7350; this PR fixes the standalone topbar surface specifically. Detected by Tactual. WCAG 1.4.11 Non-text Contrast.
How Has This Been Tested?
npm run test:unit— all suites pass (829 tests)npm run build— cleanhtml.dark-modeandforced-colors: activeat capture time. Topbar elements show diffs only in HCM scenarios; non-HCM scenarios are byte-identicalScreenshots
Same swagger-ui commit on both ports, only this patch differing. The
html.dark-modeclass is irrelevant to the topbar surface in HCM (the OS substitutes Canvas/CanvasText regardless), so only the HCM scheme axis has distinct visual states.HCM light:
HCM dark:
Out of scope
<select>chevron in HCM (HTTPS dropdown in_topbar.scssand the dark-mode select arrow in_dark-mode.scss):<select>is a replaced element with no usable pseudo-element; themask-imageapproach used in fix(a11y): restore icon visibility in Windows High Contrast Mode #10846 can't apply without wrapping the<select>in a markup change. Followup PR.Checklist
My PR contains...
src/is unmodified: changes to documentation, CI, metadata, etc.)package.json)My changes...
Documentation
Automated tests