Skip to content

Ensure conditions match question type#2867

Open
thomasiles wants to merge 6 commits into
mainfrom
ensure_conditions_match_question_type_tmp
Open

Ensure conditions match question type#2867
thomasiles wants to merge 6 commits into
mainfrom
ensure_conditions_match_question_type_tmp

Conversation

@thomasiles

Copy link
Copy Markdown
Contributor

Make conditions match the question type, if changed

Trello card: https://trello.com/c/lDyxaMH5/3145-if-a-question-with-an-unconditional-route-is-changed-to-a-select-one-list-question-set-all-the-options-to-go-to-the-same-target

When a question is changed to selection type which supports routing from multiple options, we need to make sure the conditions are updated to match.

This commit adds a new method which is called when a question is changed. It updates conditions to based on the selection options for the new question.

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Do the end to end tests need updating before these changes will pass?
  • Has all relevant documentation been updated?

When a question is changed to selection type which supports routing from
multiple options, we need to make sure the conditions are updated to
match.

This commit adds a new method which is called when a question is
changed. It updates conditions to based on the selection options for
the new question.
@thomasiles thomasiles marked this pull request as ready for review June 25, 2026 12:33
When the answer type for a question with conditions is changed, we show
a banner warning the user that the routes will be deleted.

When changing the answer type in a form with multiple branches, we do
not want to show this banner as the conditions are not being deleted.

This commit hides the banner when the answer type is changed in a form
with multiple branches.
Comment thread app/views/pages/type_of_answer.html.erb Outdated
Comment thread spec/views/pages/type_of_answer.html.erb_spec.rb Outdated
@thomasiles thomasiles force-pushed the ensure_conditions_match_question_type_tmp branch from dc24632 to 688e10d Compare June 26, 2026 15:52
@github-actions

Copy link
Copy Markdown

🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-2867.admin.review.forms.service.gov.uk/

It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready
after 5 minutes, there may be something wrong with the ECS task. You will need to go to the integration AWS account
to debug, or otherwise ask an infrastructure person.

For the sign in details and more information, see the review apps wiki page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants