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

Provide additional context for authorization and logout button #8999

Conversation

vmware-jaret
Copy link
Contributor

Description

  • Introduced the AuthorizeButton component that entails the apply authorization and remove authorization functionality, as well as a close button.
  • Unit tests provided for different states.
  • AuthorizeButton is able to be used for both form submit and onClick function behavior.

Motivation and Context

Fixes #8998, mainly to provide additional context in what the user can do by clicking 'Autorize' and 'Remove Authorization'.

How Has This Been Tested?

Used the swagger-react in another product and have seen that the hidden labels are added. Unittest added + Cypress test fixed.

Screenshots (if appropriate):

Screenshot 2023-07-05 at 15 22 21

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.

@vmware-jaret
Copy link
Contributor Author

@char0n Conscious of your limited time reviewing all the PRs and reported issues, would be nice to get some feedback both about the reported issue/enhancement and if the PR content makes sense.

@vmware-jaret
Copy link
Contributor Author

@tim-lai Hello, could you review this PR or let me know how to expedite any review / comments?

@char0n
Copy link
Member

char0n commented Aug 23, 2023

Hi @vmware-jaret,

Thank you for the PR! Your changeset is on my radar, and I'll address it ASAP.

@char0n
Copy link
Member

char0n commented Aug 31, 2023

@vmware-jaret,

I'm not sure I fully understand the underlying intention correctly, but as far as I understand you want additional context for screen readers. Wouldn't this be achieved by ad-hoc aria-label HTML attribute instead of creating rather complex AuthorizeButton usecase component?

Original code:

<div className="auth-btn-wrapper">
  {
    nonOauthDefinitions.size === authorizedAuth.size ? <Button className="btn modal-btn auth" onClick={ this.logoutClick }>Logout</Button>
      : <Button type="submit" className="btn modal-btn auth authorize">Authorize</Button>
  }
  <Button className="btn modal-btn auth btn-done" onClick={ this.close }>Close</Button>
</div>

More accessibility:

<div className="auth-btn-wrapper">
  {
    nonOauthDefinitions.size === authorizedAuth.size ? <Button className="btn modal-btn auth" onClick={ this.logoutClick }>Logout</Button>
      : <Button type="submit" className="btn modal-btn auth authorize" aria-label="Apply authorization credentials">Authorize</Button>
  }
  <Button className="btn modal-btn auth btn-done" onClick={ this.close }>Close</Button>
</div>

- Introduced the AuthorizeButton component that entails the apply authorization and remove authorization functionality, as well as a close button.
- Unit tests provided for different states.
- AuthorizeButton is able to be used for both form submit and onClick function behavior.
@vmware-jaret vmware-jaret force-pushed the ft/8998-extend-authorize-button-with-labels branch from 8ab51c5 to 4b6d389 Compare September 6, 2023 11:51
- Reverted the AuthorizationButton as <label /> is not needed and `aria-label` seems to be better fit for screen readers (see as well https://www.w3.org/WAI/WCAG21/Techniques/html/H44 that <label /> is not usable for <button /> or <input type="submit" /> HTML elements).
- Validation test for that aria-label is available for OAuth2 authorization and non-oauth2 authorization buttons.
@vmware-jaret
Copy link
Contributor Author

vmware-jaret commented Sep 6, 2023

Thanks @char0n. After some analysis indeed the <label /> element is not suitable for <input type='submit' /> or <button /> elements, hence changing to aria-label and removed the AuthorizationButton type all together.
Screenshot 2023-09-06 at 15 01 00
Screenshot 2023-09-06 at 15 01 43

Copy link
Member

@char0n char0n left a comment

Choose a reason for hiding this comment

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

LGTM!

@char0n
Copy link
Member

char0n commented Sep 7, 2023

Hi @vmware-jaret,

I've changed Logout label slightly to more match the context of the page. The PR is approved, and thank you again for opening this topic.

@char0n char0n merged commit 2c04153 into swagger-api:master Sep 7, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve accessibility for Authorization buttons
2 participants