-
Notifications
You must be signed in to change notification settings - Fork 328
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
Add "None of these" and "or" divider to checkboxes #2151
Add "None of these" and "or" divider to checkboxes #2151
Conversation
Very pleased to see this. I've been tripped up several times confused why my separator wasn't working. |
Following a conversation with the team and with @frankieroberto - we've agreed that Frankie will add a JavaScript enhancement to the PR, that unchecks all the other checkboxes, if a 'None of the above' checkbox is checked. Before @frankieroberto starts work though, we'll catch up to agree on the Nunjucks macro API - the card for that is here: #2152 |
This is no longer blocked, now that we’ve agreed the API in #2152. I've done the initial javascript implementation. Would welcome any initial feedback or suggestions. I tried to avoid making too many unrelated changes to the checkboxes javascript (eg to align it more closely with the radios javascript), but that could be considered. I’ll write the tests next. |
I've now added some tests, both to test the macro template output, and to test the checking/unchecking behaviour. |
Added suggestions to guidance content in the PR ahead of going to review by the Design System working group. |
@calvin-lau-sig7 thanks! I've made some changes based on your suggestions. Have also added a paragraph about labelling the option. |
I recognise the need for users to explicitly choose ‘none of the above’. However I’m concerned with the specific solution in this pull request. Taking this question as an example:
I appreciate the ‘divider’ goes some way to help sighted users but I think the solution has the potential to exclude certain people. My other concern with this is that by putting it in the design system we're encouraging the use of this pattern over other, potentially clearer/more accessible solutions. See 3 alternative examples below. Example 1: adding a guard question beforehand
Example 2: Marking/hinting the question as optionalHere I’ve used hint text but you could put something in the legend so it's harder to miss.
Example 3: Having an explicit option not as a checkboxThis could be more useful when the user needs to specifically disclose ‘none of the above’.
|
Just as a variation on @adamsilver's example #3 - in line with the new equality information pattern, you could say something like 'If you do not have any of these qualifications, continue without checking any of the boxes'.
|
Hey @adamsilver!
No, but it is a reasonable answer to the question "Which of these qualifications do you have?" isn't it?
I think the 'or' divider which you're missing from your example helps here. Plus I'm not sure anyone would expect to be able to select None and another option - that wouldn't make sense, so I don't think it's relying on the 'or' only. On your alternatives:
|
Hey @joelanman - all good points...
I appreciate this is not a clear cut thing. Perhaps as a slight variant:
Yep - I'm not sure either so I think it's worth a test especially when we're messing with convention. I also made an edit to my initial comment to acknowledge the value of the divider to sighted users - not sure if you saw that.
Yep - the reason I mention it is because at the very least I think the design system should give other options that might work better for certain contexts before this one is recommended (if this solution does end up being added).
Yep - but maybe that's the same for any field that's optional. Perhaps the ‘if you have any’ could be added to the legend. On top of this they'd have a check answers to make sure they're happy with their answers.
Yep, I don't love this and I would look to avoid this too. But then I haven't tested/iterated this in anger. I guess I just feel that something like this should be tested more thoroughly with a range of users with different abilities before being added to the design system. And perhaps alongside a range of approaches that might be better depending on the context. I also think we might want to a few content designers to review this pattern. |
@adamsilver good points! Agree we should highlight the alternatives, like we do on other patterns like accordions and tabs for example - if a guard question can be simple its probably the better option (Do you have a car > What make of car do you have)
I think we need to make the distinction between a required question where the answer can be 'None of these' (we need the answer) and an optional question where we don't need an answer. So a question with 'None' could easily be a required question. |
worth noting that we used None of these on a Coronavirus service recently and it tested well, and it was used a lot on the recent census. |
It would be good for the guidance to note that sometimes a guard question is a better solution - but as @joelanman notes, there are also lots of times where it's incompatible with what you're asking. I don't agree it increases cognitive load - if anything it's easier as you're making sure there's always an answer that the user can select from. If you were doing this data collection in conversation with a user / over the phone, it's the sort of answer you'd expect from them verbally. I've seen this used in multiple services over the years (as well as ones I've worked on) - IMHO it's rather well tested. |
Another idea would be to split up into separate questions like this:
|
For me, the paper form looks like you can tick, for example, 'Working as an employee' and 'OR none of the above'. If a user does select these items, this would require the Census team to interpret the user's answer or follow up with them. In any case, it seems prudent to avoid this design. |
In the digital version proposed this would not be possible |
To digress from the early conversation around the need for this feature, I'd like to explore the choice of Exclusive suggests there's a A boolean option maps more closely to the |
the idea is |
Yep, assuming JavaScript was available. |
This is looking good @frankieroberto, thanks. It'd be good to tidy up the commit history a bit, as I think quite a few of the commits could be squashed without losing anything important, and there's a few merge commits in there that ideally we'd lost. However, I think it's worth getting a second review from another member of the team first, in case anything else comes up. Does that sound sensible? |
@36degrees second review sounds good. 👍 Happy to force push some squashed commits at the end (I tend to avoid doing that as it can break things for anyone else who's fetched the branch), but every project has its own policy! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've given this a quick once-over: looked at the code; tested in Chrome, Firefox and Safari on macOS, and Chrome on Android (real device).
I couldn't find any issues, it all looks good to me!
Brill, thanks @lfdebrux for reviewing 🙌🏻 @frankieroberto are you able to look at tidying up the commit structure now? |
…le attribute. This fixes a bug/edge-case where if you use two separate calls to the macro within the same `<form>` and specify the same `name` attribute value for both sets of checkboxes, but only one of them has the `exclusive` behaviour or the conditional content, then checking a checkbox in one list would not uncheck the "None" checkbox in the other list, as there was no `eventListener` set up. Always initialising the javascript for every set of checkboxes solves this. This does introduce a small performance penalty of potentially initialising javascript when it's not needed, but this should be negligible and non-blocking.
0629a0a
to
1042a8e
Compare
@36degrees squashed into 5 commits (and reordered them a bit). Does that look ok? Been a while since I did so much command-line git... 😄 |
That's great, thanks for sorting that @frankieroberto 👍🏻 |
Did anyone see any instances of citizens highlighting that it has changed their selection without them noticing? Example: They selected a checkbox above, then selected the none checkbox. Did they expect a warning or anything like that? I had a query asked of me regarding the difference in state changes when Java is on vs off. |
@a184studio from a different perspective, with javascript we can avoid an error message. Which should hopefully make things simpler for users. |
in terms of expectations, in research we've seen people expect that if you select None it deselects the others, and vice versa |
It's worth noting that the Mutually exclusive component in the ONS Design system does add some visually hidden text in order to announce this:
However we didn't have any direct evidence that this was required. |
Cheers all. |
Has anyone done anything on checkboxes being a positive action vs a negative one. I'm investigating the ability to check items that are wrong vs right. Which in reality means that they would be selecting 24/25 checkboxes. [Tick] EG. Select all that are incorrect Any insights are grateful. |
@a184studio this PR has now been closed, and the only people that are likely to see your comment are the people who have previously contributed to this discussion. Can I suggest instead adding a comment to the backlog discussion for checkboxes, where more people are likely to see it? For more visibility, it might also be worth asking in the #design channel on cross-government Slack, if that is something you have access to. |
Following conversation about the checkboxes component, this adds the "divider" feature from the Radios component to the Checkboxes component.
The main use for the divider is to add an "or" before a "None of these option", which allows a user to explicitly state that none of the checkboxes apply, rather than having to infer (or be given guidance) that they can leave all the checkboxes unticked. This has the additional benefit of being able to validate that the user has selected at least one checkbox, avoiding a potential issue where a user accidentally doesn't check a relevant checkbox, and the service assuming this meant that none of them were relevant. Services should also check that the "None of these" option wasn't ticked as well as another checkbox, and if so display a relevant error message.
In order to help users avoid accidentally selecting an option as well as "None of these", some javascript is included which prevents this from happening, by unchecking all other checkboxes when checking a "None of these" checkbox, and by unchecking the "None of these" checkbox when checking any other checkbox. This behaviour can be enabled by passing
behaviour: "exclusive"
as a param on a checkbox item.➡️ PR which adds guidance on this to the Design System website
Example showing use within Nunjucks macro:
Example HTML output
Examples of the checkbox divider in use on live services