Happens when trying to bind to an object with more than one property. See:
Open binding editor
Type binding of {a:1, b:2 }
Observe
This happens because we're using Monaco editor to edit javascript expressions, but it's handling this input as a declaration, hence it see a block scope instead of an object.
The problem can be worked around by adding parentheses around the expression
Possible solution
There doesn't seem to be language services that deal with javascript expressions, but one approach could be to create a variant of the editor that starts with the content:
Upvoting, I expected this to work when binding the body with content-type: json. It worked with strings, arrays, so I kind of expected it to work with JSON too.
Steps to reproduce 🕹
Happens when trying to bind to an object with more than one property. See:
{a:1, b:2 }
This happens because we're using Monaco editor to edit javascript expressions, but it's handling this input as a declaration, hence it see a block scope instead of an object.
The runtime side of things is addressed by https://github.com/mui/mui-toolpad/pull/1542
The problem can be worked around by adding parentheses around the expression
Possible solution
There doesn't seem to be language services that deal with javascript expressions, but one approach could be to create a variant of the editor that starts with the content:
And disables line 1 and 3 from being edited, then strips lines 1 and 3 before firing
onChange
. (Some inspiration here: https://github.com/microsoft/monaco-editor/issues/953). Another direction could besetHiddenAreas
. It seems to be removed from the types, but it's still functional https://github.com/microsoft/monaco-editor/issues/45