Skip to content

Commit

Permalink
Use React's AriaAttributes type directly rather than recreating (#4941
Browse files Browse the repository at this point in the history
)

* Update types for aria-invalid

* Reference React's AriaAttributes type rather than redefining

* Use AriaAttributes reference in AriaGuidanceProps

* Add changeset

* Update sour-socks-boil.md

Co-authored-by: Nathan Bierema <nbierema@gmail.com>
  • Loading branch information
prichey and Methuselah96 committed Jan 13, 2022
1 parent 5b7c81a commit 54f9538
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/sour-socks-boil.md
@@ -0,0 +1,5 @@
---
'react-select': patch
---

Use React's AriaAttributes type directly rather than recreating
17 changes: 7 additions & 10 deletions packages/react-select/src/Select.tsx
@@ -1,5 +1,6 @@
import * as React from 'react';
import {
AriaAttributes,
Component,
FocusEventHandler,
FormEventHandler,
Expand All @@ -14,11 +15,7 @@ import LiveRegion from './components/LiveRegion';

import { createFilter, FilterOptionOption } from './filters';
import { DummyInput, ScrollManager } from './internal/index';
import {
AriaLive,
AriaLiveMessages,
AriaSelection,
} from './accessibility/index';
import { AriaLiveMessages, AriaSelection } from './accessibility/index';

import {
classNames,
Expand Down Expand Up @@ -75,15 +72,15 @@ export interface Props<
Group extends GroupBase<Option>
> {
/** HTML ID of an element containing an error message related to the input**/
'aria-errormessage'?: string;
'aria-errormessage'?: AriaAttributes['aria-errormessage'];
/** Indicate if the value entered in the field is invalid **/
'aria-invalid'?: boolean;
'aria-invalid'?: AriaAttributes['aria-invalid'];
/** Aria label (for assistive tech) */
'aria-label'?: string;
'aria-label'?: AriaAttributes['aria-label'];
/** HTML ID of an element that should be used as the label (for assistive tech) */
'aria-labelledby'?: string;
'aria-labelledby'?: AriaAttributes['aria-labelledby'];
/** Used to set the priority with which screen reader should treat updates to live regions. The possible settings are: off, polite (default) or assertive */
'aria-live'?: AriaLive;
'aria-live'?: AriaAttributes['aria-live'];
/** Customize the messages used by the aria-live component */
ariaLiveMessages?: AriaLiveMessages<Option, IsMulti, Group>;
/** Focus the control when it is mounted */
Expand Down
5 changes: 2 additions & 3 deletions packages/react-select/src/accessibility/index.ts
@@ -1,3 +1,4 @@
import type { AriaAttributes } from 'react';
import {
ActionMeta,
GroupBase,
Expand All @@ -11,8 +12,6 @@ export type OptionContext = 'menu' | 'value';

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

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

export type AriaSelection<Option, IsMulti extends boolean> =
| InitialInputFocusedActionMeta<Option, IsMulti>
| (ActionMeta<Option> & {
Expand All @@ -23,7 +22,7 @@ export type AriaSelection<Option, IsMulti extends boolean> =

export interface AriaGuidanceProps {
/** String value of selectProp aria-label */
'aria-label': string | undefined;
'aria-label': AriaAttributes['aria-label'];
/** String indicating user's current context and available keyboard interactivity */
context: GuidanceContext;
/** Boolean value of selectProp isSearchable */
Expand Down
1 change: 0 additions & 1 deletion packages/react-select/src/index.ts
Expand Up @@ -46,7 +46,6 @@ export * from './types';
export type {
OptionContext,
GuidanceContext,
AriaLive,
AriaGuidanceProps,
AriaOnChangeProps,
AriaOnFilterProps,
Expand Down

0 comments on commit 54f9538

Please sign in to comment.