fix(a11y): replace <pre> with <span> for version labels#10902
Open
yogeshwaran-c wants to merge 1 commit into
Open
fix(a11y): replace <pre> with <span> for version labels#10902yogeshwaran-c wants to merge 1 commit into
yogeshwaran-c wants to merge 1 commit into
Conversation
Render API and OAS version stamps inside <span> elements instead of <pre>. The <pre> tag is intended for preformatted blocks of computer code, not short inline labels, so screen readers and other assistive tooling treated the version badges as code blocks. Update the .info .title small selector to match .version (the className already on the elements) so the existing typography and reset styles continue to apply unchanged. Fixes swagger-api#10481
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
Render the API version stamp and OAS version stamp inside
<span>elements instead of<pre>so the version badges in theinfoblock are no longer marked up as preformatted code blocks.src/core/components/version-stamp.jsx—<small><pre className="version">…</pre></small>-><small><span className="version">…</span></small>src/core/components/openapi-version.jsx—<small class="version-stamp"><pre className="version">OAS …</pre></small>-><span className="version">OAS …</span>inside the same<small>src/style/_information.scss— descendant selector under.info .title smallswitched frompreto.version(the className that was already on the element) so the existing reset andtext_headlinetypography still apply.Motivation and Context
<pre>is reserved for preformatted blocks of computer code or ASCII figures. Wrapping a short, decorative version label in<pre>misleads assistive tech (screen readers may announce it as a code block) and was flagged in the linked issue.Fixes #10481
How Has This Been Tested?
npx jest --config ./config/jest/jest.unit.config.js test/unit/components/version-stamp.jsx-> 4/4 passing. New tests assert no<pre>is rendered and the.versionelement still contains the version text for both<VersionStamp/>and<OpenAPIVersion/>.npx cypress run --spec test/e2e-cypress/e2e/a11y/version-stamp.cy.js-> 2/2 passing againstpetstore-expanded.openapi.yaml. Asserts the version stamps render without a<pre>element and that the.versionelement still exists and is visible.npx eslinton the changed JS/JSX -> clean.npx stylelint src/style/_information.scss-> clean.Screenshots
No visual change is expected —
<pre>was already styled viasmall pre { margin:0; padding:0; … }and the matching SCSS rule was updated to.version. The badge still renders inline with the same typography and background.Checklist