swagger-api / swagger-api/swagger-ui
a11y: Links must not be embedded in buttons
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Q&A (please complete the following information)
- OS: [e.g. macOS] Windows 10
- Browser: [e.g. chrome, safari] Chrome
- Version: [e.g. 22] 121
- Method of installation: [e.g. npm, dist assets] npm
- Swagger-UI version: [e.g. 3.10.0] Swagger UI React 5.11.3
- Swagger/OpenAPI version: [e.g. Swagger 2.0, OpenAPI 3.0] OpenAPI 3.0
Content & configuration
Basic/default configuration
Describe the bug you're encountering
We use a tool called Sort Site to evaluate conformance with 508 accessibility. It is reporting "The interactive element "a" must not appear as a descendent of the "button" element" as well as "The element "a" must not appear as a descendent of the "button" element." Violates WCAG 2.0 A 4.1.1 https://www.w3.org/TR/2008/REC-WCAG20-20081211/#ensure-compat-parses
This is happening on the link with class "nostyle" contained in the span with class "opblock-summary-path" contained within the div with class "opblock-summary-ath-description-wrapper".
To reproduce...
This is occurring on the "path" in the heading of a POST method, but I'm sure other method types too.
Expected behavior
Buttons should not contain links. Either format the link to look like a button or replace the link with plain text.
Screenshots
Here's the code for the rendered page where the link is highlighted. Note that it is contained within a button 4 levels above the .
Additional context or thoughts
This error happens a LOT. It seems like an easy fix that would solve a bunch of problems.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the rendered elements with classes opblock-summary-path and opblock-summary-ath-description-wrapper, then trace them to the Swagger UI source. Remove the nested link or change the surrounding control so buttons do not contain links, and verify the rendered POST operation no longer produces the reported accessibility violation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- accessibility, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100