From 7af44151946a3cf101ef6fa31594a68e4723c3a2 Mon Sep 17 00:00:00 2001 From: Preston Richey Date: Mon, 6 Dec 2021 13:35:39 -0500 Subject: [PATCH 1/5] Update types for aria-invalid --- packages/react-select/src/Select.tsx | 3 ++- packages/react-select/src/accessibility/index.ts | 2 ++ packages/react-select/src/index.ts | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/react-select/src/Select.tsx b/packages/react-select/src/Select.tsx index 758eb44511..0ee417bf99 100644 --- a/packages/react-select/src/Select.tsx +++ b/packages/react-select/src/Select.tsx @@ -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, @@ -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; /** Aria label (for assistive tech) */ 'aria-label'?: string; /** HTML ID of an element that should be used as the label (for assistive tech) */ diff --git a/packages/react-select/src/accessibility/index.ts b/packages/react-select/src/accessibility/index.ts index cc8eb64ad5..2f308e4994 100644 --- a/packages/react-select/src/accessibility/index.ts +++ b/packages/react-select/src/accessibility/index.ts @@ -11,6 +11,8 @@ export type OptionContext = 'menu' | 'value'; export type GuidanceContext = 'menu' | 'input' | 'value'; +export type AriaInvalid = boolean | 'false' | 'true' | 'grammar' | 'spelling'; + export type AriaLive = 'polite' | 'off' | 'assertive'; export type AriaSelection = diff --git a/packages/react-select/src/index.ts b/packages/react-select/src/index.ts index c94bbbe63a..5e0c176062 100644 --- a/packages/react-select/src/index.ts +++ b/packages/react-select/src/index.ts @@ -46,6 +46,7 @@ export * from './types'; export type { OptionContext, GuidanceContext, + AriaInvalid, AriaLive, AriaGuidanceProps, AriaOnChangeProps, From a6c99bdbf5fd1f75dc48012a7c656d4de260fbe1 Mon Sep 17 00:00:00 2001 From: Preston Richey Date: Wed, 8 Dec 2021 11:31:10 -0500 Subject: [PATCH 2/5] Reference React's AriaAttributes type rather than redefining --- packages/react-select/src/Select.tsx | 18 +++++++----------- .../react-select/src/accessibility/index.ts | 4 ---- packages/react-select/src/index.ts | 2 -- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/packages/react-select/src/Select.tsx b/packages/react-select/src/Select.tsx index 0ee417bf99..efe1089ab4 100644 --- a/packages/react-select/src/Select.tsx +++ b/packages/react-select/src/Select.tsx @@ -1,4 +1,5 @@ import React, { + AriaAttributes, Component, FocusEventHandler, FormEventHandler, @@ -13,12 +14,7 @@ import LiveRegion from './components/LiveRegion'; import { createFilter, FilterOptionOption } from './filters'; import { DummyInput, ScrollManager } from './internal/index'; -import { - AriaInvalid, - AriaLive, - AriaLiveMessages, - AriaSelection, -} from './accessibility/index'; +import { AriaLiveMessages, AriaSelection } from './accessibility/index'; import { classNames, @@ -75,15 +71,15 @@ export interface Props< Group extends GroupBase