question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting current page number for surveys with visibleIfs leads to incorrect behaviour

See original GitHub issue

Are 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:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
andrewtelnovcommented, Mar 25, 2019

@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

0reactions
andrewtelnovcommented, Mar 25, 2019

You are welcome!

Thank you, Andrew

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting current page number for surveys with visibleIfs leads to ...
Here are a couple of examples where the current page number being rendered is incorrect. I've fed the data to the survey as...
Read more >
R. Gratton's research works | The Astronomical Observatory of ...
This page lists the scientific contributions of an author, who either does not have a ResearchGate profile, or has not yet added these...
Read more >
HabEx_Interim_Report.pdf - Jet Propulsion Laboratory - NASA
The HabEx concept design relies on demonstrated, yet cutting edge, technologies wherever possible, which enables world-leading science in the 2030s while ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found