`clearInvisibleValues: 'onHidden'` makes survey nullify some question values while loading data
See original GitHub issueAre you requesting a feature, reporting a bug or asking a question?
question
What is the current behavior?
I need to use clearInvisibleValues: 'onHidden'
(it’s a requirement) but when I use visibleIf
targeting a question whose value depends on some async events I got an undesired behaviour. I created a plunk to show this
https://plnkr.co/edit/YQxFPTAsv0zgz0R0
If you rerun the survey multiple times you’ll see that foo question loses its initial value. Looking at the console you’ll see how the survey data evolves. In my understanding there is a moment when copyCountry gets null and, as a consequence, foo gets undefined too. Is this explanation correct? Of course, removing clearInvisibleValues: 'onHidden'
solves but for me it is essential when the user interact with the survey. To be more precise I don’t need it in the “data loading phase” while I need it later during user interaction. I think this survey property can be changed at runtime but how can I know when surveyJS has finished to run all expressions and choicesByUrl stuff and its ready for editing? This leads me again to this old unresolved issue https://github.com/surveyjs/survey-library/issues/1871
Curiously this does not happen without paneldynamic.
https://plnkr.co/edit/vaqoo5Xnnwmf1pYZ
Is this all expected?
thanks a lot
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Hello,
Let me, please, explain my thoughts about this situation. I think there is no way to solve this problem in general case on SurveyJS side. Just because there is an dependency graph (not tree) in general case
E.g. I modified your plunker. I set the expression question calculate value equal to text question. And text question visible if expression is not empty. Also clearInvisibleValues on hidden. What we got?
Let’s imagine case 1:
Otherwise imagine case 2:
What of this these two cases is true? No answer. There is no right case. So this problem hasn’t solution in general case with that amount of information which we have at SurveyJS library side
So as a result I can suggest you process your business logic with various SurveyJS events such as onValueChanged or onVisibleChanged. You can also count loaded questions to detect when survey is loaded according to your business logic
Thanks, Alex SurveyJS Team
Hello,
In your case the situation is absolutely the same as I described above Imagine this case:
This is one of valid scenarios. You can use onVisibleChanged event to set question value equal to default value when question will became visible
Thanks, Alex SurveyJS Team