Text Editor shows up for Text only parameters. (#9014)

- Fix type name so that Text Editor shows for parameters.
- Following on from #9010, now show the default text values.
![image](https://github.com/enso-org/enso/assets/4699705/da68fec4-25b9-4e04-ba13-a2d112cf67c9)
This commit is contained in:
James Dunkerley 2024-02-09 17:26:15 +00:00 committed by GitHub
parent 9339672e0e
commit aed59d316d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

@ -187,7 +187,7 @@ test('Managing aggregates in `aggregate` node', async ({ page }) => {
'.',
'Count_Distinct',
])
await expect(columnsArg.locator('.EnsoTextInputWidget > input')).toHaveValue('"column 1"')
await expect(columnsArg.locator('.EnsoTextInputWidget > input').first()).toHaveValue('"column 1"')
// Add another aggregate
await columnsArg.locator('.add-item').click()
@ -222,7 +222,7 @@ test('Managing aggregates in `aggregate` node', async ({ page }) => {
await dropDown.expectVisibleWithOptions(page, ['column 1', 'column 2'])
await dropDown.clickOption(page, 'column 2')
await expect(secondItem.locator('.WidgetToken')).toHaveText(['Aggregate_Column', '.', 'Group_By'])
await expect(secondItem.locator('.EnsoTextInputWidget > input')).toHaveValue('"column 2"')
await expect(secondItem.locator('.EnsoTextInputWidget > input').first()).toHaveValue('"column 2"')
// Switch aggregates
//TODO[ao] I have no idea how to emulate drag. Simple dragTo does not work (some element seem to capture event).

View File

@ -10,7 +10,9 @@ const props = defineProps(widgetProps(widgetDefinition))
const value = computed({
get() {
const valueStr = WidgetInput.valueRepr(props.input)
return valueStr ?? ''
return typeof valueStr === 'string' && Ast.parse(valueStr) instanceof Ast.TextLiteral
? valueStr
: ''
},
set(value) {
props.onUpdate({
@ -27,7 +29,7 @@ export const widgetDefinition = defineWidget(WidgetInput.isAstOrPlaceholder, {
if (props.input.value instanceof Ast.TextLiteral) return Score.Perfect
if (props.input.dynamicConfig?.kind === 'Text_Input') return Score.Perfect
const type = props.input.expectedType
if (type === 'Standard.Base.Data.Text') return Score.Good
if (type === 'Standard.Base.Data.Text.Text') return Score.Good
return Score.Mismatch
},
})