Merge remote-tracking branch 'upstream/master' into fix/web-driver-tests-v6-circleci-config

Conflicts:
	package-lock.json
	src/components/inputs/AutocompleteInput.jsx
This commit is contained in:
orangemug
2018-01-22 09:57:54 +00:00
9 changed files with 91 additions and 103 deletions

View File

@@ -57,11 +57,22 @@ class AddModal extends React.Component {
componentWillUpdate(nextProps, nextState) {
// Check if source is valid for new type
const availableSources = this.getSources(nextState.type);
const oldType = this.state.type;
const newType = nextState.type;
const availableSourcesOld = this.getSources(oldType);
const availableSourcesNew = this.getSources(newType);
if(
this.state.source !== ""
&& availableSources.indexOf(this.state.source) < 0
// Type has changed
oldType !== newType
&& this.state.source !== ""
// Was a valid source previously
&& availableSourcesOld.indexOf(this.state.source) > -1
// And is not a valid source now
&& availableSourcesNew.indexOf(nextState.source) < 0
) {
// Clear the source
this.setState({
source: ""
});
@@ -90,7 +101,7 @@ class AddModal extends React.Component {
}
for(let [key, val] of Object.entries(this.props.sources)) {
if(types[val.type].indexOf(type) > -1) {
if(types[val.type] && types[val.type].indexOf(type) > -1) {
sources.push(key);
}
}