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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments in Calculated Value prevent the value being displayed #5795

Open
vijaivir opened this issue Sep 5, 2024 · 2 comments
Open

Comments in Calculated Value prevent the value being displayed #5795

vijaivir opened this issue Sep 5, 2024 · 2 comments
Assignees

Comments

@vijaivir
Copy link

vijaivir commented Sep 5, 2024

Describe the bug
Our users have some calculated values in their Text Field component that do not display if a comment is made after the value is calculated.

For example, if a text field has the API property name set to A and a second text field uses a calculated value of value = data.A, the second field mirrors the input from the first. But if a comment is added value = data.A //comment, the text field remains blank.

I understand this is because the entire calculated value is evaluated as a string in the calculateValue property of the form's JSON, and adding a comment at the end does not return any value. Is that correct?

Is this a bug that can be fixed?

Version/Branch
Sandbox (Default)

To Reproduce
Steps to reproduce the behavior:

  1. Navigate to: https://formio.github.io/formio.js/app/sandbox.html
  2. Enter Sandbox id: 66da30361aeaa15811339869 and Load Sandbox
  3. Navigate to 'Form Rendered' at the bottom of the page
  4. Enter something in the 'Text Field (A)'

Expected behavior
The value should be displayed in both text fields.

Screenshots

Screenshot 2024-09-05 at 3 42 32 PM

@jgrott
Copy link

jgrott commented Sep 10, 2024

hi, formio is glueing 'return value' to the end of the script, so in your case that would be

//test comment return value

in that scenario return is a part of the comment so will be omitted by the evaluator

would be nice if formio team could fix that by glueing return to the new line, or maybe even by requiring return statement from users (makes sense especially when we're using if statements with early returns)

the fast workaround is just placing comments not on the last line of script

@daneformio
Copy link
Contributor

We have created a ticket for this. In the meantime, if you would like to submit a pull request, we would review it.
Ticket for internal tracking: FIO-8803

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants