Merge branch 'master' into patch-1

This commit is contained in:
Jim LAURIE 2018-11-20 14:47:15 +01:00 committed by GitHub
commit 855b282e0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,7 @@ import React from 'react';
import Select from 'react-select';
import { FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types';
import { cloneDeep, isArray, isNull, isUndefined, get, findIndex, isEmpty } from 'lodash';
import { cloneDeep, includes, isArray, isNull, isUndefined, get, findIndex, isEmpty } from 'lodash';
// Utils.
import request from 'utils/request';
@ -103,6 +103,15 @@ class SelectMany extends React.PureComponent {
});
};
handleInputChange = (value) => {
const clonedOptions = this.state.options;
const filteredValues = clonedOptions.filter(data => includes(data.label, value));
if (filteredValues.length === 0) {
return this.getOptions(value);
}
}
handleChange = value => {
// Remove new added value from available option;
this.state.options = this.state.options.filter(el =>
@ -169,6 +178,7 @@ class SelectMany extends React.PureComponent {
id={this.props.relation.alias}
isLoading={this.state.isLoading}
onChange={this.handleChange}
onInputChange={this.handleInputChange}
onMenuScrollToBottom={this.handleBottomScroll}
options={this.state.options}
placeholder={<FormattedMessage id='content-manager.containers.Edit.addAnItem' />}