mirror of
https://github.com/strapi/strapi.git
synced 2025-09-20 14:00:48 +00:00
Merge branch 'master' into patch-1
This commit is contained in:
commit
855b282e0d
@ -8,7 +8,7 @@ import React from 'react';
|
|||||||
import Select from 'react-select';
|
import Select from 'react-select';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import PropTypes from 'prop-types';
|
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.
|
// Utils.
|
||||||
import request from 'utils/request';
|
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 => {
|
handleChange = value => {
|
||||||
// Remove new added value from available option;
|
// Remove new added value from available option;
|
||||||
this.state.options = this.state.options.filter(el =>
|
this.state.options = this.state.options.filter(el =>
|
||||||
@ -169,6 +178,7 @@ class SelectMany extends React.PureComponent {
|
|||||||
id={this.props.relation.alias}
|
id={this.props.relation.alias}
|
||||||
isLoading={this.state.isLoading}
|
isLoading={this.state.isLoading}
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
|
onInputChange={this.handleInputChange}
|
||||||
onMenuScrollToBottom={this.handleBottomScroll}
|
onMenuScrollToBottom={this.handleBottomScroll}
|
||||||
options={this.state.options}
|
options={this.state.options}
|
||||||
placeholder={<FormattedMessage id='content-manager.containers.Edit.addAnItem' />}
|
placeholder={<FormattedMessage id='content-manager.containers.Edit.addAnItem' />}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user