From c37e86d8eaa3f6eba83696453a58d525cce6c7c6 Mon Sep 17 00:00:00 2001 From: Rall3n Date: Wed, 2 Nov 2022 21:27:39 +0100 Subject: [PATCH] Add `required` prop (#4882) * Add `required` prop * Add changeset * Add braces around `if` * Extend test cases * Add `aria-required` * Remove `requiredMessage` prop * Remove `requiredMessage` from default props --- .changeset/violet-readers-listen.md | 5 +++ packages/react-select/src/Select.tsx | 23 +++++++++-- .../src/__tests__/Select.test.tsx | 40 +++++++++++++++++++ .../src/__tests__/StateManaged.test.tsx | 20 ++++++++++ .../src/internal/RequiredInput.tsx | 30 ++++++++++++++ packages/react-select/src/internal/index.ts | 1 + 6 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 .changeset/violet-readers-listen.md create mode 100644 packages/react-select/src/internal/RequiredInput.tsx diff --git a/.changeset/violet-readers-listen.md b/.changeset/violet-readers-listen.md new file mode 100644 index 0000000000..e13f958084 --- /dev/null +++ b/.changeset/violet-readers-listen.md @@ -0,0 +1,5 @@ +--- +'react-select': minor +--- + +Add `required` prop diff --git a/packages/react-select/src/Select.tsx b/packages/react-select/src/Select.tsx index 30e67458b3..11076fc810 100644 --- a/packages/react-select/src/Select.tsx +++ b/packages/react-select/src/Select.tsx @@ -14,7 +14,7 @@ import { MenuPlacer } from './components/Menu'; import LiveRegion from './components/LiveRegion'; import { createFilter, FilterOptionOption } from './filters'; -import { DummyInput, ScrollManager } from './internal/index'; +import { DummyInput, ScrollManager, RequiredInput } from './internal/index'; import { AriaLiveMessages, AriaSelection } from './accessibility/index'; import { @@ -262,6 +262,8 @@ export interface Props< value: PropsValue