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.11k stars 799 forks source link

Ranking order is lost when survey is reloaded #8836

Open digiscapeuk opened 2 hours ago

digiscapeuk commented 2 hours ago

Consider a survey such as the attached: ranking bug.json

I've simplified the use case to illustrate the issue.

We have a set of user entered values - in this case it is there goals. The user could enter up to 3 but it's optional whether they fill all of them out.

Once the user has entered their goals we'd like a later step to be ranking them in order of priority.

We can set the options in the ranking question by pulling the text from the earlier question and hide options that would be blank.

Ranking the options works fine and is stored correctly in the JSON on save.

The problem we are seeing is that when the survey is reloaded the ranking is lost and reverts to the initial sort that matches the order of items in the multipletext question.

I would expect it populate the choices using the earlier question but reapply the ranking using the data that was loaded from the json we have stored.

Documentation talks about feeding ranking questions with choices from other questions but that isn't appropriate for this use case.

JaneSjs commented 2 hours ago

Hello @digiscapeuk, Thank you for sharing your usage scenario. I reproduced the issue on my end (View Demo). Regardless of the changed sequence of Ranking items, they appear in their initial order:

survey.data = {
        "goals": {
            "goal1": "11",
            "goal3": "33"
        },
        "rankedGoals": [
            "3",
            "1"
        ]
};

image

We'll research this issue and let you know our results. Please stay tuned.