From c67b431af3f57be9f81d73ac3073fb8962de1c8e Mon Sep 17 00:00:00 2001 From: Louis Eugene Date: Fri, 23 Oct 2020 12:45:53 -0700 Subject: [PATCH 1/2] Expressions not starting with "=" can resolve to a regular TextField --- .../src/utils/resolveFieldWidget.ts | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Composer/packages/adaptive-form/src/utils/resolveFieldWidget.ts b/Composer/packages/adaptive-form/src/utils/resolveFieldWidget.ts index 546a95595a..5b3280a92c 100644 --- a/Composer/packages/adaptive-form/src/utils/resolveFieldWidget.ts +++ b/Composer/packages/adaptive-form/src/utils/resolveFieldWidget.ts @@ -58,8 +58,24 @@ export function resolveFieldWidget(params: { return { field: DefaultFields.OneOfField }; } - if (expression && typeof value === 'string' && value.startsWith('=')) { - return { field: isOneOf ? DefaultFields.IntellisenseExpressionField : IntellisenseExpressionFieldWithIcon }; + if (expression && typeof value === 'string') { + // The schema has two types of expressions: "equalsExpression" and "expression". + // "equalsExpression" inputs start with "=". For those we want to have access to the adaptive expressions built-in functions and have intellisense surface it, thus using IntellisenseExpressionField. + // "expression" inputs don't leverage the built-in functions. For those, we only want to show IntellisenseTextField. + if (value.startsWith('=')) { + return { field: isOneOf ? DefaultFields.IntellisenseExpressionField : IntellisenseExpressionFieldWithIcon }; + } else { + if (showIntellisense && isOneOf) { + return { field: DefaultFields.IntellisenseTextField }; + } else if (showIntellisense && !isOneOf) { + return { field: IntellisenseTextFieldWithIcon }; + } else if (!showIntellisense && !isOneOf) { + return { field: StringFieldWithIcon }; + } + return { + field: DefaultFields.StringField, + }; + } } if (Array.isArray(schema.enum)) { From 0cc08521ef716c7d6eb7f875324c486c8eba3c5c Mon Sep 17 00:00:00 2001 From: LouisEugeneMSFT <66701106+LouisEugeneMSFT@users.noreply.github.com> Date: Fri, 23 Oct 2020 12:58:56 -0700 Subject: [PATCH 2/2] Update comment --- Composer/packages/adaptive-form/src/utils/resolveFieldWidget.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Composer/packages/adaptive-form/src/utils/resolveFieldWidget.ts b/Composer/packages/adaptive-form/src/utils/resolveFieldWidget.ts index 5b3280a92c..8262c02af5 100644 --- a/Composer/packages/adaptive-form/src/utils/resolveFieldWidget.ts +++ b/Composer/packages/adaptive-form/src/utils/resolveFieldWidget.ts @@ -61,7 +61,7 @@ export function resolveFieldWidget(params: { if (expression && typeof value === 'string') { // The schema has two types of expressions: "equalsExpression" and "expression". // "equalsExpression" inputs start with "=". For those we want to have access to the adaptive expressions built-in functions and have intellisense surface it, thus using IntellisenseExpressionField. - // "expression" inputs don't leverage the built-in functions. For those, we only want to show IntellisenseTextField. + // "expression" inputs don't leverage the built-in functions. For those, we only want to show a regular text field (that could potentially leverage Intellisense for results other than built-in expression functions). if (value.startsWith('=')) { return { field: isOneOf ? DefaultFields.IntellisenseExpressionField : IntellisenseExpressionFieldWithIcon }; } else {