Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calculation inside non-first repeat does not run when relevancy changes #93

Open
MartijnR opened this issue Oct 19, 2021 · 2 comments
Open
Assignees
Labels
bug Something isn't working repeats

Comments

@MartijnR
Copy link
Member

MartijnR commented Oct 19, 2021

Describe the bug

  1. If a calculation without a form control inside a repeat has a relevancy dependency on another question inside that repeat, it does not get recalculated for certain calculations.
  2. When the record is validated, any non-relevant calculated values (step 4 below) are not pruned (likely similar cause).

To Reproduce

  1. Drop repeat-relevant-calc.xml.txt into test/forms (change extension to xml) and run http://localhost:8005/?xform=repeat-relevant-calc.xml (fyi, see also the XLSForm)
  2. Leave first repeat untouched and enter 8 in the 2nd repeat.
  3. See that the calculation result (1 + 1) does not update in the 2nd repeat. It should!
  4. Enter 9 in the first repeat and see that the calculation result updates in all repeats. It shouldn't!

Expected behavior
The calculation in the second repeat should update when it becomes relevant (step 3).
The calculation in the second repeat should not update when the first repeat becomes relevant (step 4).
The calculation in the third repeat should not update when the first repeat becomes relevant (step 4).

Additional context
I suspect the issue is with the relative path in the relevant expression. I've already confirmed that the calculations do not run (so it's not an <output> issue)

@MartijnR
Copy link
Member Author

I'll take a shot at this.

@MartijnR
Copy link
Member Author

MartijnR commented Oct 20, 2021

This TODO seems to describe the issue.

Wow, calculations with a relevant condition and without form controls (i.e. no labels nor hints) are thoroughly broken inside repeats (and probably always have been). I'm not sure if this is fixable without fixing the long-desired placement of #calculated-items in the correct <form>DOM location (i.e. getting rid of the #calculated-items group) where they belong #853...

Another solution would be to ignore the relevant expression entirely if something doesn't have a form control (except for pruning when a record is marked as final). This may actually be more XForms compliant. However, the pruning probably doesn't work for the same reason, so this solves the problem of calculating but keeps the problem with pruning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working repeats
Projects
None yet
Development

No branches or pull requests

2 participants