Skip to content

Commit f6052bd

Browse files
committed
Add support for custom string input
1 parent f2c454d commit f6052bd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/connect-react/src/components/ControlSelect.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ export function ControlSelect<T>({
9696
MenuList: LoadMore,
9797
}
9898
}
99+
100+
const handleCreate = (inputValue: string) => {
101+
options.unshift({
102+
label: inputValue,
103+
value: inputValue,
104+
})
105+
};
106+
99107
const MaybeCreatableSelect = isCreatable
100108
? CreatableSelect
101109
: Select;
@@ -110,6 +118,7 @@ export function ControlSelect<T>({
110118
required={!prop.optional}
111119
{...props}
112120
{...selectProps}
121+
onCreateOption={handleCreate}
113122
onChange={(o) => {
114123
if (o) {
115124
if (Array.isArray(o)) {

0 commit comments

Comments
 (0)