Commit c5d8e899 authored by George Goldberg's avatar George Goldberg

Fix MultiSelect compatability with react-select v2.0.0 (#2120)

* Fix MultiSelect compatability with react-select v2.0.0

* Make it a function.
parent 83c4c6ab
......@@ -57,6 +57,20 @@ export default class MultiSelectSetting extends React.Component {
}
}
calculateValue = () => {
return this.props.selected.reduce((values, item) => {
const found = this.props.values.find((e) => {
return e.value === item;
});
if (found !== null) {
values.push(found);
}
return values;
}, []);
};
getOptionLabel = ({text}) => text;
render() {
return (
<Setting
......@@ -67,15 +81,15 @@ export default class MultiSelectSetting extends React.Component {
>
<ReactSelect
id={this.props.id}
multi={true}
labelKey='text'
isMulti={true}
getOptionLabel={this.getOptionLabel}
options={this.props.values}
joinValues={true}
delimiter={','}
clearable={false}
disabled={this.props.disabled || this.props.setByEnv}
noResultsText={this.props.noResultText}
onChange={this.handleChange}
value={this.props.selected}
value={this.calculateValue()}
/>
<FormError error={this.state.error}/>
</Setting>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment