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

Use React's AriaAttributes type directly rather than recreating #4941

Merged
merged 8 commits into from Jan 13, 2022
3 changes: 2 additions & 1 deletion packages/react-select/src/Select.tsx
Expand Up @@ -14,6 +14,7 @@ import LiveRegion from './components/LiveRegion';
import { createFilter, FilterOptionOption } from './filters';
import { DummyInput, ScrollManager } from './internal/index';
import {
AriaInvalid,
AriaLive,
AriaLiveMessages,
AriaSelection,
Expand Down Expand Up @@ -76,7 +77,7 @@ export interface Props<
/** HTML ID of an element containing an error message related to the input**/
'aria-errormessage'?: string;
/** Indicate if the value entered in the field is invalid **/
'aria-invalid'?: boolean;
'aria-invalid'?: AriaInvalid;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of redefining AriaInvalid, can we do AriaAttributes['aria-invalid'] here (and import AriaAtributes from react)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, definitely. I'll make that change now

Copy link
Contributor Author

@prichey prichey Dec 8, 2021

Choose a reason for hiding this comment

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

Do you think it's worth updating the other aria attributes to pull from that type for the sake of consistency? @Methuselah96

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you're up for that, that would be great. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done ✅

/** Aria label (for assistive tech) */
'aria-label'?: string;
/** HTML ID of an element that should be used as the label (for assistive tech) */
Expand Down
2 changes: 2 additions & 0 deletions packages/react-select/src/accessibility/index.ts
Expand Up @@ -11,6 +11,8 @@ export type OptionContext = 'menu' | 'value';

export type GuidanceContext = 'menu' | 'input' | 'value';

export type AriaInvalid = boolean | 'false' | 'true' | 'grammar' | 'spelling';
prichey marked this conversation as resolved.
Show resolved Hide resolved

export type AriaLive = 'polite' | 'off' | 'assertive';

export type AriaSelection<Option, IsMulti extends boolean> =
Expand Down
1 change: 1 addition & 0 deletions packages/react-select/src/index.ts
Expand Up @@ -46,6 +46,7 @@ export * from './types';
export type {
OptionContext,
GuidanceContext,
AriaInvalid,
AriaLive,
AriaGuidanceProps,
AriaOnChangeProps,
Expand Down