Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace info component check for externalDocs to use externalDocsUrl #6981

Closed
wants to merge 1 commit into from

Conversation

ndsprinkle
Copy link

Description

This change modifies the logic check for displaying the external documentation link in the Info component to now check the externalDocsUrl variable instead of the externalDocs variable.

Motivation and Context

Fixes #6975

This change is necessary to prevent the rendering of the Link component when there is no external documentation link provided. This is causing an accessibility issue as links are being rendered without associated URLs.

Currently, externalDocs is checked here, so if externalDocs is truthy, then the Link component is rendered. However, externalDocs is always a truthy value. This is because even when externalDocs is not defined in the given API object, it is assigned new Map() here, which is a truthy value. My solution is to check externalDocsUrl instead, which is already pulled from externalDocs, as this is the actual value being displayed in the Link component.

Previously, externalDocsUrl was used here instead of externalDocs. From what I can tell, the change was made here, but I am not sure if there was a specific reason for changing this logic. I see no issue in returning to checking externalDocsUrl as this is a variable already being assigned and the primary subject of the rendered Link component.

How Has This Been Tested?

This was identified and tested using our implementation in the Department of Veteran Affair's developer portal repository. We were upgrading our version of swagger-ui to the latest and noticed failing accessibility tests due to links being rendered without URLs in places where no externalDocs object was provided in the API object. Conversely, in places where the externalDocs object was provided, the link was rendered as expected.

Without our accessibility tests, we wouldn't have been able to identify this issue because links were visually being shown when provided and not shown when not provided. The issue was, as explained, that the Link object was still being rendered even when no link was provided, which causes issues with screen readers.

Checklist

My PR contains...

  • No code changes (src/ is unmodified: changes to documentation, CI, metadata, etc.)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fixes (non-breaking change which fixes an issue)
  • Improvements (misc. changes to existing features)
  • Features (non-breaking change which adds functionality)

My changes...

  • are breaking changes to a public API (config options, System API, major UI change, etc).
  • are breaking changes to a private API (Redux, component props, utility functions, etc.).
  • are breaking changes to a developer API (npm script behavior changes, new dev system dependencies, etc).
  • are not breaking changes.

Documentation

  • My changes do not require a change to the project documentation.
  • My changes require a change to the project documentation.
  • If yes to above: I have updated the documentation accordingly.

Automated tests

  • My changes can not or do not need to be tested.
  • My changes can and should be tested by unit and/or integration tests.
  • If yes to above: I have added tests to cover my changes.
  • If yes to above: I have taken care to cover edge cases in my tests.
  • All new and existing tests passed.

@ndsprinkle ndsprinkle marked this pull request as ready for review February 22, 2021 22:22
@tim-lai
Copy link
Contributor

tim-lai commented Feb 24, 2021

@ndsprinkle Thanks for the PR! Due to merge issues that I'll blame on Github, I had to create a replacement PR, #6997. Thanks for the fix!

@tim-lai tim-lai closed this Feb 24, 2021
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.

Empty link rendered when no external docs
2 participants