InseeFr / Lunatic

Library of questionnaire components
https://inseefr.github.io/Lunatic/
MIT License
20 stars 21 forks source link

Resizing loop : lose every missing response #1045

Open QRuhier opened 3 months ago

QRuhier commented 3 months ago

Describe the bug

When we resize a loop (adding/deleting an iteration) , the remaining iterations keep there values, except their missing values

To Reproduce

Steps to reproduce the behavior:

  1. questionnaire : issue_1045.json
  2. page 2 : set 1 person
  3. page 3, 4.1, 4.2 : give answer, then missing, then answer (whatever the order, it's just to have both for seing problem)
  4. go back to page 2 : change to 2 persons
  5. go back to the loop for your 1st person : the answers you gave remain 👍 but missings values have disappeared 👎

It is the same if for example you had 3 iterations then changed to 2 : the missings for the 2 remaining iterations disappear

Expected behavior

When resizing a loop, the remaining iterations should keep their answers, including missing responses

Version where the bug appeared

Observed on 3.1.0, but was already on 2.7

Browser where the bug was tested

Additional context

Add any other context about the problem here.

Grafikart commented 3 months ago

Le comportement est "normal" au vu du code :

Pour améliorer ce comportement une solution serait lors d'un resizing vers une valeur plus grande de ne pas changer directement la variable (ici T_AN) mais plutôt de définir une nouvelle valeur a un nouvel index. Cela implique donc de changer le comportement du resizing (à voir si c'est satisfaisant ou pas)