From 7a3e1410a497507e0db90c4c58d2f11cabe25e32 Mon Sep 17 00:00:00 2001 From: Elias Meire Date: Thu, 15 Aug 2024 15:43:25 +0200 Subject: [PATCH] fix(editor): Highlight matching type in filter component (#10425) --- .../components/FilterConditions/Condition.vue | 10 +++++++ .../FilterConditions/OperatorSelect.vue | 29 ++++++++++++------- .../FilterConditions/__tests__/utils.test.ts | 15 +++++++++- .../src/components/FilterConditions/types.ts | 10 +++++-- .../src/components/FilterConditions/utils.ts | 21 +++++++++++++- 5 files changed, 70 insertions(+), 15 deletions(-) diff --git a/packages/editor-ui/src/components/FilterConditions/Condition.vue b/packages/editor-ui/src/components/FilterConditions/Condition.vue index 71efc75728223..00d83218c1b3e 100644 --- a/packages/editor-ui/src/components/FilterConditions/Condition.vue +++ b/packages/editor-ui/src/components/FilterConditions/Condition.vue @@ -17,6 +17,7 @@ import { type FilterOperatorId } from './constants'; import { getFilterOperator, handleOperatorChange, + inferOperatorType, isEmptyInput, operatorTypeToNodeProperty, resolveCondition, @@ -70,6 +71,14 @@ const conditionResult = computed(() => resolveCondition({ condition: condition.value, options: props.options }), ); +const suggestedType = computed(() => { + if (conditionResult.value.status !== 'resolve_error') { + return inferOperatorType(conditionResult.value.resolved.leftValue); + } + + return 'any'; +}); + const allIssues = computed(() => { if (conditionResult.value.status === 'validation_error' && !isEmpty.value) { return [conditionResult.value.error]; @@ -176,6 +185,7 @@ const onBlur = (): void => {