fix(editor): Fix breaking Drop-downs after removing expressions (#3094)

* 🐛 Fixed multiOption parameter input dropdown values after removing expression.

* ♻️ Moved array value normalization to removeExpression action.

* 🐛 Handled scenario where expression contained invalid value.
This commit is contained in:
Alex Grozav 2022-04-15 08:35:51 +03:00 committed by GitHub
parent 47bbe9857b
commit 17b0cd8f76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -421,7 +421,7 @@ export default mixins(
return false;
},
expressionValueComputed (): NodeParameterValue | null {
expressionValueComputed (): NodeParameterValue | string[] | null {
if (this.areExpressionsDisabled) {
return this.value;
}
@ -733,7 +733,7 @@ export default mixins(
this.$emit('textInput', parameterData);
},
valueChanged (value: string | number | boolean | Date | null) {
valueChanged (value: string[] | string | number | boolean | Date | null) {
if (value instanceof Date) {
value = value.toISOString();
}
@ -768,7 +768,14 @@ export default mixins(
this.expressionEditDialogVisible = true;
this.trackExpressionEditOpen();
} else if (command === 'removeExpression') {
this.valueChanged(this.expressionValueComputed !== undefined ? this.expressionValueComputed : null);
let value = this.expressionValueComputed;
if (this.parameter.type === 'multiOptions' && typeof value === 'string') {
value = (value || '').split(',')
.filter((value) => (this.parameterOptions || []).find((option) => option.value === value));
}
this.valueChanged(typeof value !== 'undefined' ? value : null);
} else if (command === 'refreshOptions') {
this.loadRemoteParameterOptions();
}