Skip to content

Add aria-describedby attribute #4082

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

bladey
Copy link
Contributor

@bladey bladey commented Jun 11, 2020

As per PR #3273, updated again master and new tests.

@bladey bladey added category/accessibility Issues or PRs related to accessibility pr/in-review PRs currently in review by maintainers for the next release enhancement labels Jun 11, 2020
@changeset-bot
Copy link

changeset-bot bot commented Jun 11, 2020

💥 No Changeset

Latest commit: 1f2614c

Merging this PR will not cause any packages to be released. If these changes should not cause updates to packages in this repo, this is fine 🙂

If these changes should be published to npm, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@bladey bladey linked an issue Jun 11, 2020 that may be closed by this pull request
@bladey bladey added the pr/priority PRs that should be addressed sooner rather than later label Jun 11, 2020
@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 1f2614c:

Sandbox Source
react-codesandboxer-example Configuration

@darkowic
Copy link

Nice! I just run into an issue with it. 🚀 Waiting for it to be released! @JedWatson

@darkowic
Copy link

Btw what about support for other aria attributes like aria-required etc?

@kiranyedidi
Copy link

I opened a PR (#4132) to add the aria attributes in a generic way. Please have a look at it.

@bladey bladey added pr/in-review PRs currently in review by maintainers for the next release and removed pr/in-review PRs currently in review by maintainers for the next release labels Aug 24, 2020
Copy link

@kylemh kylemh left a comment

Choose a reason for hiding this comment

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

Small adjustment to comments, but this looks great.

@@ -75,6 +75,8 @@ type FormatOptionLabelMeta = {
};

export type Props = {
/* HTML ID of an element that should be used to describe this input (for assistive tech) */
Copy link

Choose a reason for hiding this comment

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

This and labelledby should actually not have language in the comments that suggests a single element, as both of those props accept a separated LIST of IDs.

https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-labelledby_attribute

A space-separated list of element IDs

Suggested change
/* HTML ID of an element that should be used to describe this input (for assistive tech) */
/* A space-separated list of element IDs that should be used to describe this input (for assistive tech) */

@@ -75,6 +75,8 @@ type FormatOptionLabelMeta = {
};

export type Props = {
/* HTML ID of an element that should be used to describe this input (for assistive tech) */
'aria-describedby'?: string,
/* Aria label (for assistive tech) */
'aria-label'?: string,
/* HTML ID of an element that should be used as the label (for assistive tech) */
Copy link

Choose a reason for hiding this comment

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

Suggested change
/* HTML ID of an element that should be used as the label (for assistive tech) */
/* A space-separated list of element IDs that should be used as the label (for assistive tech) */

@@ -75,6 +75,8 @@ type FormatOptionLabelMeta = {
};

export type Props = {
Copy link

@kylemh kylemh Dec 8, 2020

Choose a reason for hiding this comment

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

An alternative suggestion:

import { AriaAttributes } from 'react';

// ...

// aria attributes makes the JSX "noisy", separated for clarity
const ariaAttributes = {
  'aria-autocomplete': 'list',
  'aria-describedby': this.props['aria-describedby'],
  'aria-label': this.props['aria-label'],
  'aria-labelledby': this.props['aria-labelledby'],
  'aria-required': this.props['aria-required'],
  'aria-invalid': this.props['aria-invalid'],
};

export type Props = Pick<AriaAttributes, keyof typeof ariaAttributes> & {
  // ... the other props
};
type Demo = keyof typeof ariaAttributes;
// Demo --> 'aria-autocomplete' | 'aria-describedby' | 'aria-label' | 'aria-labelledby'

@noelleleigh
Copy link

@bladey Any chance this PR could be rebased and reviewed? Our team would love to use React Select, but the lack of support for directly specifying aria-describedby is a real concern.

@ryanscottaudio
Copy link

@bladey same here, would love some 👀 on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category/accessibility Issues or PRs related to accessibility pr/in-review PRs currently in review by maintainers for the next release pr/priority PRs that should be addressed sooner rather than later
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding support for aria-describedby attribute
7 participants