Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binding editor doesn't accept object expressions #1543

Open
Janpot opened this issue Jan 11, 2023 · 1 comment
Open

Binding editor doesn't accept object expressions #1543

Janpot opened this issue Jan 11, 2023 · 1 comment
Labels
bug 馃悰 Something doesn't work

Comments

@Janpot
Copy link
Member

Janpot commented Jan 11, 2023

Steps to reproduce 馃暪

Happens when trying to bind to an object with more than one property. See:

  1. Open binding editor
  2. Type binding of {a:1, b:2 }
  3. Observe

Screenshot 2023-01-11 at 14 47 52

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 #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:

1   return (
2    // type expression here
3   );

And disables line 1 and 3 from being edited, then strips lines 1 and 3 before firing onChange. (Some inspiration here: microsoft/monaco-editor#953). Another direction could be setHiddenAreas. It seems to be removed from the types, but it's still functional microsoft/monaco-editor#45

@mnajdova
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 馃悰 Something doesn't work
Projects
None yet
Development

No branches or pull requests

2 participants