Skip to content

Commit

Permalink
fix(editor): Fix breaking Drop-downs after removing expressions (#3094)
Browse files Browse the repository at this point in the history
* 🐛 Fixed multiOption parameter input dropdown values after removing expression.

* ♻️ Moved array value normalization to removeExpression action.

* 🐛 Handled scenario where expression contained invalid value.
  • Loading branch information
alexgrozav authored Apr 15, 2022
1 parent 47bbe98 commit 17b0cd8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/editor-ui/src/components/ParameterInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ export default mixins(
return false;
},
expressionValueComputed (): NodeParameterValue | null {
expressionValueComputed (): NodeParameterValue | string[] | null {
if (this.areExpressionsDisabled) {
return this.value;
}
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 17b0cd8

Please sign in to comment.