Skip to content

Conversation

mperrotti
Copy link
Contributor

These changes fix accessibility defects called out in this comment: https://github.com/github/primer/issues/1495#issuecomment-1332693886

These changes also include updates to ActionMenu that allow us to reference the DOM node that labels the menu.

Closes https://github.com/github/primer/issues/1495

Screenshots

There should be no visual changes

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@mperrotti mperrotti requested review from a team and siddharthkp January 25, 2023 21:43
@changeset-bot
Copy link

changeset-bot bot commented Jan 25, 2023

🦋 Changeset detected

Latest commit: 5b74f4f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Jan 25, 2023

size-limit report 📦

Path Size
dist/browser.esm.js 94.54 KB (+0.04% 🔺)
dist/browser.umd.js 95.13 KB (+0.05% 🔺)

@github-actions github-actions bot temporarily deployed to storybook-preview-2815 January 25, 2023 21:49 Inactive
@primer primer bot temporarily deployed to github-pages January 25, 2023 21:53 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2815 January 25, 2023 21:54 Inactive
…er/react into mp/segmented-control-a11y-eng-fixes
@mperrotti mperrotti temporarily deployed to github-pages January 25, 2023 22:00 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2815 January 25, 2023 22:00 Inactive
@kendallgassner
Copy link
Contributor

is there a storybook / doc preview available?

@mperrotti
Copy link
Contributor Author

@kendallgassner - there is a preview deployment.

Here is the docs page: https://primer-f38a78541d-13348165.drafts.github.io/SegmentedControl

Here are the Storybook stories: https://primer-f38a78541d-13348165.drafts.github.io/storybook/?path=/story/components-segmentedcontrol-features--associated-with-a-label-and-caption

None of the link's paths have changed since your review, you just have to look at them on https://primer-f38a78541d-13348165.drafts.github.io/ intead of https://primer.style/react/

@kendallgassner
Copy link
Contributor

kendallgassner commented Jan 26, 2023

Accessibility Review

Documentation

  • - Would it be possible to add a documentation note that this component should not be used in a form?

Semantics

  • - I only see the semantics being used in this way on the doc site. Specifically on with a label above and caption below but right now 'File Name' is a semantic label this feels wrong because the component is not a form element (input, select, etc.) We should make this a span instead... I am confused though because the storybook examples do in fact show the File Name as a span.
    A couple of issues in the icon-only story / SegmentedControlIconButton
    • - This example uses the incorrect aria attribute: aria-pressed. The buttons should not act as 'toggle buttons' because users cannot toggle the buttons on/off by clicking on them they must click on a different button to switch the selection. Solution: replace aria-pressed with aria-current .
    • - I notice you are trying to use the tooltip component to label each icon button. With our rails tooltip, this would work great but our react tooltip is not accessible. There is no association between the tooltip text and the icon button so screen reader users only hear 'toggle button selected'. The fix here would be to fix the tooltip component to match the semantics/aria attributes of the rails tooltip (aria-labelledby).
  • - In the Variant action menu story, there is no name or label to associate with the menu options. We need to require a sr-only label if an engineer uses a variant drop-down.

Zoom

  • - (Tested at 400% ✅ ) If I zoom into the fullwidth narrow story I notice that the component's button text moves outside of the button. We will likely have users who need to zoom into the page to view content.
    Zoomed in on segmented control story fullwidth narrow. The text goes outside of the segmented control container

  • - When a segmented control includes a label we should move the segmented control to a new line on mobile. For example, if you view associated with a label and caption story on a mobile screen the user must scroll to navigate to the segmented control. The user should not have to scroll to view content.

Misc.

  • - I noticed a really tiny CSS bug while reviewing the component. The line separating the second button from the third button appears over the focus indicator when the second button is focused.
    Zoomed into a storybook example of Segmented control. When the first button is active but the second button has focus the line separating the buttons appears over the focus ring.

  • - In our deep dive today, @jscholes noticed that the preview something besides the first button selected did in fact have the first button selected.

@kendallgassner
Copy link
Contributor

kendallgassner commented Jan 26, 2023

  • - In the Variant action menu story, there is no name or label to associate with the menu options. We need to require a sr-only label if an engineer uses a variant drop-down.

Technically we are not 'requiring' this but all the examples are labeled. @mperrotti can we throw a console warning if there is no aria-labelledby or aria-label in the action menu case


<Note variant="warning">

A `SegmentedControl` should not be used in a form as a replacement for something like a [RadioGroup](/RadioGroup) or [Select](/Select). See the [Accessibility section](https://primer.style/design/components/segmented-control#accessibility) of the SegmentedControl interface guidelines for more details.
Copy link
Contributor

Choose a reason for hiding this comment

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

<3

@mperrotti
Copy link
Contributor Author

can we throw a console warning if there is no aria-labelledby or aria-label in the action menu case

We already do :)

@mperrotti
Copy link
Contributor Author

mperrotti commented Jan 27, 2023

@kendallgassner - the inaccessible tooltip is a known issue for @primer/react. We're working on a fix (PR) so we can make it accessible, but it's blocked right now.

I'm going to fix the styling issue you pointed out and re-request a review. It would be nice to merge these other fixes and just leave the a11y review issue open until we replace the tooltip.

@github-actions github-actions bot temporarily deployed to storybook-preview-2815 January 31, 2023 18:51 Inactive
Copy link
Contributor

@kendallgassner kendallgassner left a comment

Choose a reason for hiding this comment

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

Thank you for all of these fixes!

@mperrotti mperrotti temporarily deployed to github-pages February 4, 2023 00:42 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2815 February 4, 2023 00:42 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2815 February 4, 2023 00:49 Inactive
@mperrotti mperrotti force-pushed the mp/segmented-control-a11y-eng-fixes branch from 3680446 to f01f437 Compare February 4, 2023 00:50
@mperrotti mperrotti temporarily deployed to github-pages February 4, 2023 00:56 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2815 February 4, 2023 00:56 Inactive
@mperrotti mperrotti temporarily deployed to github-pages February 16, 2023 17:16 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2815 February 16, 2023 17:16 Inactive
@mperrotti mperrotti temporarily deployed to github-pages February 17, 2023 15:31 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2815 February 17, 2023 15:31 Inactive
@mperrotti mperrotti temporarily deployed to github-pages February 17, 2023 19:20 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2815 February 17, 2023 19:21 Inactive
@mperrotti mperrotti enabled auto-merge February 17, 2023 19:35
@mperrotti mperrotti temporarily deployed to github-pages February 17, 2023 21:13 — with GitHub Actions Inactive
@mperrotti mperrotti added this pull request to the merge queue Feb 17, 2023
Merged via the queue into main with commit 74df59c Feb 17, 2023
@mperrotti mperrotti deleted the mp/segmented-control-a11y-eng-fixes branch February 17, 2023 21:30
@primer-css primer-css mentioned this pull request Feb 17, 2023
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.

3 participants