Setting current page number for surveys with visibleIfs leads to incorrect behaviour
See original GitHub issueAre you requesting a feature, reporting a bug or asking a question?
Reporting a bug
What is the current behavior?
I am building an application where I show the user a survey with multiple pages (each page has one question).
On answering every question I store the currentPageNo of the survey and the survey responses with onPartialSend
callback.
I store the current-page number since if the user refreshes the page, I populate the survey with whatever answers already given, and bring the user to the last-answered question. I do this by means of passing the answers in the data
property and setting the page number in the currentPageNo
property. Everything was working as intended when the survey questions were simple (no conditionals like visibleIfs).
I’ve encountered a couple of scenarios with some surveys(with visibleIfs in the survey-json) where after answering some questions and refreshing the page, the incorrect page number, and hence the incorrect question, is being displayed by the survey component. Printing the currentPageNo in onAfterRenderSurvey
callback makes it clear.
Here are a couple of examples where the current page number being rendered is incorrect. I’ve fed the data to the survey as if its already refreshed.
How would you reproduce the current behavior (if this is a bug)?
Example 1 - This contains a simple survey-json with 4 questions Survey without visibleif. Setting the current-page-no works properly. https://plnkr.co/edit/YmR8r2Mk0AfHwLyDfFjg?p=preview
Survey with visibleif Setting the current-page-no as 2 does not seem to work https://plnkr.co/edit/fztrUdbUcbGbTxCOoaFP?p=preview
Example 2 - A complex survey-json where the current-page number is incorrect https://plnkr.co/edit/f7796gy1f87RpOezxijR?p=preview
Although the current-page-no is set to 9, it always jumps to 11 on rendering.
NOTE: All the currentPageNo values being set in examples are basically the values returned from survey-js after answering every question. I am hard-coding them in the example to make it easy to demonstrate the issue.
Specify your
- browser: Firefox
- browser version: 64.0.2 (64-bit)
- surveyjs platform (angular or react or jquery or knockout or vue): react
- surveyjs version: 1.0.66
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
@gnithin I have changed your first plunker and it works now. The problem, that it is important how to set here. You should set at first data, so the visibleIf should work and hide (questions/pages) before setting currentPageNo. Otherwise, the result maybe incorrect.
Thank you, Andrew
You are welcome!
Thank you, Andrew