OpenClinica / enketo-oc

OpenClinica's fork of the Enketo web forms monorepo
Apache License 2.0
0 stars 1 forks source link

Select item with choice filter in repeating group shows incorrect value in view mode #92

Open pbowen-oc opened 2 years ago

pbowen-oc commented 2 years ago

Present in 2.5.6.oc-17 and 2.8.0.oc branch. Related to OpenClinica/enketo-express-oc#503 but still not working when tested with that fix.

Steps:

  1. Open this form in view mode: Repeat Choice Filter1.xform.txt using this instance: Repeat Choice Filter1.instance.txt The value in the first repeat was entered and then cleared, the second repeat was left empty, and a value was entered in the third repeat.

Expected: The first and second groups show the item as null and the third group shows the item with a value.

Actual: All three groups show the item with a value.

Edit mode (correct): Screenshot 2021-11-16 203232

View mode (incorrect): Screenshot 2021-11-16 203307

The same happens if the form is viewed without the instance. For example:

Steps:

  1. Open this blank form in view mode: Repeat Choice Filter1.xform.txt

Expected: The item in the repeating group will show a null value.

Actual: The item shows a value.

In practice, the behavior is that the first choice that matches the choice filter is being displayed as the item value (instead of the expected null) when the form is viewed. Edit mode still shows the null value as expected.

MartijnR commented 2 years ago

empty: http://localhost:8005/single/fs/i/Y7eqyLo8?ecid=1 readonly: http://localhost:8005/view/fs/i/8d428b60ddb0739744928bfddb9da8a2?ecid=1

I can reproduce in master. Something to do with setting question to readonly.

The same happens in the underlying <select> element. It looks to be caused by an itemset widget not copying the disabled attribute. Interestingly the native selectpicker will 'select' the first non-disabled option.

I think the fix would be for itemset.js to look at whether the <select> is disabled and if so make any dynamically added <option>s also disabled.

MartijnR commented 2 years ago

Requires 2 PRs to be merged:

and after that to update enketo-express-(oc) with new Enketo Core and Enketo Transformer

pbowen-oc commented 2 years ago

@MartijnR - We deployed the PRs for Transformer and Core on top of the 2.8.0.oc branch but the issue was still present. Do you think the fix needs other changes from master or there is some other issue?

MartijnR commented 2 years ago

I don't know at the moment. Was Enketo Transformer updated in enketo-express-oc? It should be. I can see that may have not been so clear. Enketo Transformer is only used to run tests in Enketo Core (so doesn't actually have to be updated in Enketo Core for this fix - but fine to do so).

pbowen-oc commented 1 year ago

@MartijnR - Is this fully merged into our master branch?

MartijnR commented 1 year ago

Yes, confirmed.

pbowen-oc commented 1 year ago

I added the ready-for-final-review tag based on the most recent comment.