Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions Composer/packages/adaptive-form/src/utils/resolveFieldWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Could merge else and else if to just else ifs

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)) {
Expand Down