@@ -4,14 +4,32 @@ import FormControl from '@material-ui/core/FormControl';
44import MuiSelect from '@material-ui/core/Select' ;
55
66class Select extends React . Component {
7+
8+ constructor ( props ) {
9+ super ( props ) ;
10+ this . state = {
11+ selectOpen : false ,
12+ } ;
13+ }
14+
15+ handleOpen = ( ) => {
16+ this . setState ( { selectOpen : true } ) ;
17+ } ;
18+
19+ handleClose = ( ) => {
20+ this . setState ( { selectOpen : false } ) ;
21+ } ;
722
823 componentDidUpdate ( prevProps , prevState ) {
924 if ( this . props . commands !== prevProps . commands )
1025 this . forceUpdate ( ) ;
1126 }
1227
1328 render ( ) {
29+ const { id, multiple, pythonparams, children, onChange } = this . props ;
30+
1431 let value = this . props . value || '' ;
32+ const { selectOpen } = this . state ;
1533 if ( this . props . multiple && value . constructor . name != 'Array' ) {
1634 // when loading values from a script, we can't allow strings if *multiple* is enabled
1735 value = [ value ] ;
@@ -23,14 +41,20 @@ class Select extends React.Component {
2341 < FormControl variant = "filled" fullWidth >
2442 < InputLabel > { this . props . label } </ InputLabel >
2543 < MuiSelect
26- id = { this . props . id }
44+ id = { id }
2745 value = { value }
28- onChange = { this . props . onChange }
29- multiple = { ! ! this . props . multiple }
30- pythonparams = { this . props . pythonparams }
46+ onChange = { ( event ) => {
47+ onChange ( event ) ;
48+ this . handleClose ( ) ;
49+ } }
50+ multiple = { ! ! multiple }
51+ pythonparams = { pythonparams }
52+ open = { selectOpen }
53+ onOpen = { this . handleOpen }
54+ onClose = { this . handleClose }
3155 >
32- { this . props . children }
33- </ MuiSelect >
56+ { children }
57+ </ MuiSelect >
3458
3559 </ FormControl >
3660
0 commit comments