Fix bug with resetting operators when an incompatible value type is chosen

This commit is contained in:
Andrew Kingston 2021-07-26 12:56:47 +01:00
parent 38df0b54a5
commit 8a09494348
2 changed files with 6 additions and 6 deletions

View File

@ -125,10 +125,9 @@
condition.referenceValue = null
// Ensure a valid operator is set
const validOperators = getValidOperatorsForType(newType)
const validOperators = getValidOperatorsForType(newType).map(x => x.value)
if (!validOperators.includes(condition.operator)) {
condition.operator =
validOperators[0]?.value ?? OperatorOptions.Equals.value
condition.operator = validOperators[0] ?? OperatorOptions.Equals.value
onOperatorChange(condition, condition.operator)
}
}

View File

@ -47,10 +47,11 @@
expression.type = schemaFields.find(x => x.name === field)?.type
// Ensure a valid operator is set
const validOperators = getValidOperatorsForType(expression.type)
const validOperators = getValidOperatorsForType(expression.type).map(
x => x.value
)
if (!validOperators.includes(expression.operator)) {
expression.operator =
validOperators[0]?.value ?? OperatorOptions.Equals.value
expression.operator = validOperators[0] ?? OperatorOptions.Equals.value
onOperatorChange(expression, expression.operator)
}
}