Bugfix - order conditions in next attribute according to order their fields appear on the page to help avoid page skipping weirdness #199
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WIP - Please note that the code and PR description have been AI-generated as a rapid prototype for testing and validation
Description
We encountered a bug where users could skip pages in forms when selecting multiple checkboxes. This happened because the conditions that control page navigation were stored in the wrong order. When a user selected both "feasibility study" and "call for projects" checkboxes, the system would jump directly to the "call for projects" page and skip the "feasibility study" page entirely, because the "call for projects" condition was evaluated first in the list.
Our fix automatically sorts the navigation conditions to match the order of the checkboxes that trigger them. When a form is saved, the system now looks at the order of options in the checkbox field and reorders the corresponding conditions to match. This ensures that if "feasibility study" appears before "call for projects" in the checkbox list, its condition will also be evaluated first, preventing pages from being skipped.
This approach has some limitations. It only works for forms that use checkboxes or radio buttons to control navigation flow. If conditions are based on other types of form fields or complex logic, the sorting may not work as expected. Additionally, the fix assumes that the visual order of options should match the navigation order, which may not always be the desired behavior for all forms.
Testing