Skip to content

Commit 54f9538

Browse files
Use React's AriaAttributes type directly rather than recreating (#4941)
* 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>
1 parent 5b7c81a commit 54f9538

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

.changeset/sour-socks-boil.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'react-select': patch
3+
---
4+
5+
Use React's AriaAttributes type directly rather than recreating

packages/react-select/src/Select.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from 'react';
22
import {
3+
AriaAttributes,
34
Component,
45
FocusEventHandler,
56
FormEventHandler,
@@ -14,11 +15,7 @@ import LiveRegion from './components/LiveRegion';
1415

1516
import { createFilter, FilterOptionOption } from './filters';
1617
import { DummyInput, ScrollManager } from './internal/index';
17-
import {
18-
AriaLive,
19-
AriaLiveMessages,
20-
AriaSelection,
21-
} from './accessibility/index';
18+
import { AriaLiveMessages, AriaSelection } from './accessibility/index';
2219

2320
import {
2421
classNames,
@@ -75,15 +72,15 @@ export interface Props<
7572
Group extends GroupBase<Option>
7673
> {
7774
/** HTML ID of an element containing an error message related to the input**/
78-
'aria-errormessage'?: string;
75+
'aria-errormessage'?: AriaAttributes['aria-errormessage'];
7976
/** Indicate if the value entered in the field is invalid **/
80-
'aria-invalid'?: boolean;
77+
'aria-invalid'?: AriaAttributes['aria-invalid'];
8178
/** Aria label (for assistive tech) */
82-
'aria-label'?: string;
79+
'aria-label'?: AriaAttributes['aria-label'];
8380
/** HTML ID of an element that should be used as the label (for assistive tech) */
84-
'aria-labelledby'?: string;
81+
'aria-labelledby'?: AriaAttributes['aria-labelledby'];
8582
/** Used to set the priority with which screen reader should treat updates to live regions. The possible settings are: off, polite (default) or assertive */
86-
'aria-live'?: AriaLive;
83+
'aria-live'?: AriaAttributes['aria-live'];
8784
/** Customize the messages used by the aria-live component */
8885
ariaLiveMessages?: AriaLiveMessages<Option, IsMulti, Group>;
8986
/** Focus the control when it is mounted */

packages/react-select/src/accessibility/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { AriaAttributes } from 'react';
12
import {
23
ActionMeta,
34
GroupBase,
@@ -11,8 +12,6 @@ export type OptionContext = 'menu' | 'value';
1112

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

14-
export type AriaLive = 'polite' | 'off' | 'assertive';
15-
1615
export type AriaSelection<Option, IsMulti extends boolean> =
1716
| InitialInputFocusedActionMeta<Option, IsMulti>
1817
| (ActionMeta<Option> & {
@@ -23,7 +22,7 @@ export type AriaSelection<Option, IsMulti extends boolean> =
2322

2423
export interface AriaGuidanceProps {
2524
/** String value of selectProp aria-label */
26-
'aria-label': string | undefined;
25+
'aria-label': AriaAttributes['aria-label'];
2726
/** String indicating user's current context and available keyboard interactivity */
2827
context: GuidanceContext;
2928
/** Boolean value of selectProp isSearchable */

packages/react-select/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export * from './types';
4646
export type {
4747
OptionContext,
4848
GuidanceContext,
49-
AriaLive,
5049
AriaGuidanceProps,
5150
AriaOnChangeProps,
5251
AriaOnFilterProps,

0 commit comments

Comments
 (0)