From 8788e2a35bed261e13da5c92ee31bbb414d019a4 Mon Sep 17 00:00:00 2001 From: Elias Meire Date: Fri, 29 Mar 2024 16:01:32 +0100 Subject: [PATCH] fix(editor): UI enhancements and fixes for expression inputs (#8996) --- packages/editor-ui/src/__tests__/setup.ts | 7 ++++++ .../AssignmentCollection/Assignment.vue | 2 -- .../components/FilterConditions/Condition.vue | 2 -- .../InlineExpressionEditorOutput.vue | 25 +++++++++++-------- .../src/components/ParameterInputFull.vue | 7 +++++- .../ExpressionEditorModalInput.test.ts | 15 ----------- .../components/__tests__/HtmlEditor.test.ts | 17 ------------- .../useAutocompleteTelemetry.test.ts | 17 ------------- .../__tests__/useExpressionEditor.test.ts | 17 ------------- .../src/composables/useExpressionEditor.ts | 5 ++-- .../src/Extensions/StringExtensions.ts | 5 +++- .../StringExtensions.test.ts | 8 +++++- 12 files changed, 41 insertions(+), 86 deletions(-) diff --git a/packages/editor-ui/src/__tests__/setup.ts b/packages/editor-ui/src/__tests__/setup.ts index 9316e30a30..4c75c226e6 100644 --- a/packages/editor-ui/src/__tests__/setup.ts +++ b/packages/editor-ui/src/__tests__/setup.ts @@ -12,3 +12,10 @@ window.ResizeObserver = })); Element.prototype.scrollIntoView = vi.fn(); + +Range.prototype.getBoundingClientRect = vi.fn(); +Range.prototype.getClientRects = vi.fn(() => ({ + item: vi.fn(), + length: 0, + [Symbol.iterator]: vi.fn(), +})); diff --git a/packages/editor-ui/src/components/AssignmentCollection/Assignment.vue b/packages/editor-ui/src/components/AssignmentCollection/Assignment.vue index c1ee16976b..f18b5d5c81 100644 --- a/packages/editor-ui/src/components/AssignmentCollection/Assignment.vue +++ b/packages/editor-ui/src/components/AssignmentCollection/Assignment.vue @@ -169,7 +169,6 @@ const onBlur = (): void => { display-options hide-label hide-hint - :rows="3" :is-read-only="isReadOnly" :parameter="nameParameter" :value="assignment.name" @@ -196,7 +195,6 @@ const onBlur = (): void => { hide-label hide-issues hide-hint - :rows="3" is-assignment :is-read-only="isReadOnly" :options-position="breakpoint === 'default' ? 'top' : 'bottom'" diff --git a/packages/editor-ui/src/components/FilterConditions/Condition.vue b/packages/editor-ui/src/components/FilterConditions/Condition.vue index 18eb28b034..e3b1be0e18 100644 --- a/packages/editor-ui/src/components/FilterConditions/Condition.vue +++ b/packages/editor-ui/src/components/FilterConditions/Condition.vue @@ -156,7 +156,6 @@ const onBlur = (): void => { hide-label hide-hint hide-issues - :rows="3" :is-read-only="readOnly" :parameter="leftParameter" :value="condition.leftValue" @@ -181,7 +180,6 @@ const onBlur = (): void => { hide-label hide-hint hide-issues - :rows="3" :is-read-only="readOnly" :options-position="breakpoint === 'default' ? 'top' : 'bottom'" :parameter="rightParameter" diff --git a/packages/editor-ui/src/components/InlineExpressionEditor/InlineExpressionEditorOutput.vue b/packages/editor-ui/src/components/InlineExpressionEditor/InlineExpressionEditorOutput.vue index 65102dabbe..4c2bda3195 100644 --- a/packages/editor-ui/src/components/InlineExpressionEditor/InlineExpressionEditorOutput.vue +++ b/packages/editor-ui/src/components/InlineExpressionEditor/InlineExpressionEditorOutput.vue @@ -45,21 +45,24 @@ const resolvedExpression = computed(() => { }); const plaintextSegments = computed(() => { - if (props.segments.length === 0) { - return [ - { - from: 0, - to: resolvedExpression.value.length - 1, - plaintext: resolvedExpression.value, - kind: 'plaintext', - }, - ]; - } - return props.segments.filter((s): s is Plaintext => s.kind === 'plaintext'); }); const resolvedSegments = computed(() => { + if (props.segments.length === 0) { + const emptyExpression = resolvedExpression.value; + const emptySegment: Resolved = { + from: 0, + to: emptyExpression.length, + kind: 'resolvable', + error: null, + resolvable: '', + resolved: emptyExpression, + state: 'pending', + }; + return [emptySegment]; + } + let cursor = 0; return props.segments diff --git a/packages/editor-ui/src/components/ParameterInputFull.vue b/packages/editor-ui/src/components/ParameterInputFull.vue index ceda6d05d7..20c7a81d5d 100644 --- a/packages/editor-ui/src/components/ParameterInputFull.vue +++ b/packages/editor-ui/src/components/ParameterInputFull.vue @@ -1,6 +1,6 @@