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

radiobutton/checkboxed in nested fieldsets inadvertently setting conditional to hidden #609

Closed
nunommc opened this issue May 22, 2020 · 1 comment · Fixed by #756
Closed
Labels
checkboxes 🕙 days A few unknowns, but we roughly know what’s involved help wanted Extra attention is needed radios

Comments

@nunommc
Copy link

nunommc commented May 22, 2020

Bug Report

What is the issue?

In the example shown in the screenshot below, there are radio buttons shown only when the user chooses the first option("I am employed or self employed").
When I click in any of the radio buttons below the conditional content will then get closed and the option I just clicked on disappears.

So, on click, it's running addClass(input, 'nhsuk-radios__conditional--hidden') to all conditionalInputs in the page.

One of two things I think should happen:

  • either the addEventListener is added only to radiobuttons/checkboxes that could affect the aria-expanded;
  • find the .nhsuk-radios--conditional or nhsuk-checkboxes--conditional which is an immediate parent of the current node, and apply the toggleConditionalInput only to that;

What steps are required to reproduce the issue?

Is there anything else you think would be useful in recreating the issue?

image

@chrimesdev
Copy link
Member

chrimesdev commented May 26, 2020

Hey @nunommc,

Thanks for raising this issue, nested conditionals could work but only to reveal small amounts of information. Is the JavaScript something you think you could attempt a fix at? If so we are always open to new contributors!

Looking at the form design screenshot you have posted, whilst it’s possible to structure pages in this way, we’d recommend splitting the questions across multiple screens before nesting form elements like this - as the pages become more complex, require multiple interactions and work less well without JavaScript. You could have a simple ‘guard question’ - Are you employed? - and then ask for more detail on the next page if they answered yes. We have some guidance on how to write good questions for forms.

There also might be accessibility issues for screen reader users as you can't nest fieldsets and make it clear which legend goes with which fieldset. So this would need testing with users (not just automated checkers).

As the guidance for the conditional reveals in the NHS digital service manual says 'Keep it simple. If you need to add a lot of content, consider showing it on the next page in the process instead.'

@chrimesdev chrimesdev added the awaiting triage Needs triaging by team label May 26, 2020
@davidhunter08 davidhunter08 added component 🕙 days A few unknowns, but we roughly know what’s involved and removed awaiting triage Needs triaging by team labels Aug 3, 2020
@chrimesdev chrimesdev added the help wanted Extra attention is needed label Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
checkboxes 🕙 days A few unknowns, but we roughly know what’s involved help wanted Extra attention is needed radios
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants