surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4.09k stars 795 forks source link

Infinite Loop when referencing question value in another question's title #1522

Closed benirose closed 5 years ago

benirose commented 5 years ago

Are you requesting a feature, reporting a bug or asking a question?

Reporting a Bug

What is the current behavior?

Referencing a question value in the text of another question causes an infinite loop that crashes the browser, when using the VueJS component for SurveyJS

What is the expected behavior?

When I select an answer for question 1, the value is displayed in the text for question 2 (and the browser doesn't crash)

How would you reproduce the current behavior (if this is a bug)?

Configure a survey to have two questions one one page. First question is named goalselection, second question has reference to this value in the title, e.g. "I agree to walk {goalselection} steps every week". Display this survey using the Vue component.

NOTE: Doing this with in non-production mode (as with the provided CodeSandbox) will result in a Vue Warning that "You may have an infinite update loop in a component render function." Doing this on production will cause the browser (at least Chrome) to crash due to the infinite update loop.

Provide the test code and the tested page URL (if applicable)

Tested page URL: https://codesandbox.io/s/zlq3r359zl

Specify your

tsv2013 commented 5 years ago

I've managed to reproduce this issue. We're working on it.

tsv2013 commented 5 years ago

VueJS subscribes to the private local variable.

Fix will be available in the next minor update, most likely today

benirose commented 5 years ago

You all are amazing! Thanks for the quick response on this!

benirose commented 5 years ago

Side question that I couldn't find in the documentation: is there a way to just use the choice value instead of text?

dmitry-kurmanov commented 5 years ago

@benirose if I understand you correctly you can just use something like this:

            choices: [
                "None",
                "Ford",
                "Vauxhall",
                ...otherValues
            ]