@@ -12,6 +12,8 @@ import TrashIcon from "@material-ui/icons/Delete"
1212import CheckIcon from "@material-ui/icons/Check"
1313import UndoIcon from "@material-ui/icons/Undo"
1414import Select from "react-select"
15+ import CreatableSelect from "react-select/creatable"
16+
1517import { asMutable } from "seamless-immutable"
1618
1719const useStyles = makeStyles ( styles )
@@ -27,6 +29,7 @@ type Props = {
2729 onChange : ( Region ) => null ,
2830 onClose : ( Region ) => null ,
2931 onOpen : ( Region ) => null ,
32+ onRegionClassAdded : ( ) => { } ,
3033}
3134
3235export const RegionLabel = ( {
@@ -38,6 +41,7 @@ export const RegionLabel = ({
3841 onChange,
3942 onClose,
4043 onOpen,
44+ onRegionClassAdded,
4145} : Props ) => {
4246 const classes = useStyles ( )
4347
@@ -100,14 +104,17 @@ export const RegionLabel = ({
100104 </ div >
101105 { ( allowedClasses || [ ] ) . length > 0 && (
102106 < div style = { { marginTop : 6 } } >
103- < Select
107+ < CreatableSelect
104108 placeholder = "Classification"
105- onChange = { ( o ) =>
106- onChange ( {
109+ onChange = { ( o , actionMeta ) => {
110+ if ( actionMeta . action == "create-option" ) {
111+ onRegionClassAdded ( o . value )
112+ }
113+ return onChange ( {
107114 ...( region : any ) ,
108115 cls : o . value ,
109116 } )
110- }
117+ } }
111118 value = {
112119 region . cls ? { label : region . cls , value : region . cls } : null
113120 }
0 commit comments