Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

mejiaj
Copy link
Contributor

@mejiaj mejiaj commented Oct 5, 2020

Preview

Button group →

Description

Users should be able to add role="button" to links (using best judgement) and expect it to trigger a click on spacebar, like native buttons do.

Part of #3690.

  • Added role="button" to the link in button group.
  • Links with role="button" now behave like buttons (spacebar and enter activate).

Additional Notes

MDN on button role

Best practices

If a link performs the action of a button, giving the element role="button" helps assistive technology users understand the function of the element. However, a better solution is to adjust the visual design so it matches the function and ARIA role. Where possible, it is recommended to use native HTML buttons (, , , and ) rather than the button role, as native HTML buttons are supported by all user agents and assistive technology and provide keyboard and focus requirements by default, without need for additional customization.

Sources:
Slack thread →
Original issue →
MDN on Button role →

Before you hit Submit, make sure you’ve done whichever of these applies to you:

  • Follow the 18F Front End Coding Style Guide and Accessibility Guide.
  • Run npm test and make sure the tests for the files you have changed have passed.
  • Run your code through HTML_CodeSniffer and make sure it’s error free.
  • Title your pull request using this format: [Website] - [UI component]: Brief statement describing what this pull request solves.

@mejiaj mejiaj changed the title USWDS - Button group: Add role="button" to link in button group. USWDS - Accessibility: Add role="button" and button functionality to link in button group. Nov 13, 2020
@mejiaj mejiaj marked this pull request as ready for review November 13, 2020 17:34
@mejiaj mejiaj requested a review from thisisdano November 13, 2020 17:34
@mejiaj mejiaj added Affects: Accessibility 🟡 Relates to the accessibility of our components improves: correctness labels Nov 13, 2020
@mejiaj mejiaj requested a review from sarnikbixal November 16, 2020 17:14
@mejiaj mejiaj linked an issue Oct 25, 2021 that may be closed by this pull request
2 tasks
@mejiaj
Copy link
Contributor Author

mejiaj commented Oct 25, 2021

Todo

  • Update and rename role-button.js; remove role dependency
  • Replace buttons in USA Card components to links with the class usa-button

Expected results

Links with the class usa-button should be triggered on Spacebar or Enter. Card component examples use links with button class, instead of buttons.

@mahoneycm
Copy link
Contributor

Done and done!
#4385

Todo

  • Update and rename role-button.js; remove role dependency
  • Replace buttons in USA Card components to links with the class usa-button

@mejiaj mejiaj changed the title USWDS - Accessibility: Add role="button" and button functionality to link in button group. USWDS - Accessibility: Add button functionality to links that look like buttons. Nov 17, 2021
@mejiaj
Copy link
Contributor Author

mejiaj commented Dec 3, 2021

Closing this PR in favor of #4385.

@mejiaj mejiaj closed this Dec 3, 2021
@mejiaj mejiaj deleted the jm-button-group-a11y branch December 19, 2022 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Affects: Accessibility 🟡 Relates to the accessibility of our components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants