-
Notifications
You must be signed in to change notification settings - Fork 332
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' feature to checkboxes #1795
Comments
We need to implement this pattern on 2 pages in our service and will need to research how people deal with (we are agent facing). Our current idea is |
My service has an example of this. Screenshot below. If you check none, all other options are cleared. If you check one of the other options, none is cleared. This requires javascript so we'll also have to check this server side. NB - more generically you might call this a 'mutually exclusive' option. Any checkbox that is set to mutually exclusive will automatically clear others when set (and vice versa) |
The inverse of this is 'All' (see: https://www.euroncap.com/en/ratings-rewards/latest-safety-ratings/). |
I struggle to see what having a "None of the above" option achieves. 'None of the above' and leaving all the checkboxes blank mean the same thing, and that is what causes confusion. Isn't having a one checkbox that doesn't act like any of the other checkboxes an antipattern? Perhaps that's too strong a word, but it's at least a case of material dishonesty. |
@peteryates Yeh you're right, they do mean the same thing. The main difference, at least for us, is that one is explicit and one isn't. How can you tell the difference between accidentally submitting without checking an answer and actively not answering that question? You could obviously go down the route of "how do you know they selected any of them correctly?" But this feels like a good middle ground of removing possible user error. |
@peteryates this allows the user to positively give an answer that's clearly for them. Without it, it may be unclear for them how to proceed. I actually needed this today on a government form - none of the options seemed appropriate - but without an option like this, I may have picked one thinking that I needed to pick the most appropriate. |
@edwardhorsford In your design, have you tried separating the last item from the others with "or" text, like the Radio example: https://design-system.service.gov.uk/components/radios/#radio-items-with-a-text-divider I wonder if this text helps separate the different kind of option from the list, or if users would misinterpret checkboxes as behaving like radios because of it. |
There is also the option for the checkboxes to be preceded with a qualifying question. So before @edwardhorsford's example, something like "Do you know about some parts of the supply chain?" - that being a Yes or No question would allow the effective "none of the above" answer to be given. |
I think what might help define when you use a guard question (Do you X?) or a 'None of the above' would be how common the situation would be for users. So if it's common to have None, use a guard question, but if it's rare, use a None of the above, instead of making all users answer a guard question. |
Using a guard question seems like the cleanest approach to me. The idea of having one check box that acts differently to the others, more like a radio button, just doesn't sit right. |
I wrote a little ES6 script to deal with this:
|
Yes this is from Offer Coronavirus support from your business - I think its a good example of where None is useful. It's not easy to ask a yes/no question here as the question would be 'Can you offer expertise' when we're interested in specific types. |
Sent via @wayneddgu - another example of a service with an |
To expand more on when I think this pattern is necessary - its when there's no obvious guard question for the list. So 'Do you have a car?' easily guards 'What kind of car do you have?'. But there's no obvious guard question for 'These conditions' or 'These countries' as in the examples above. |
It would be great if the people on this thread could let us know what logic they applied for users who don't have JavaScript enabled. |
@timpaul We've not yet got any client side javascript to deselect or disable other checkboxes when 'none' is selected. This may be because with our question there isn't really room for interpretation, but can't say for certain. When we validate server side we return an error that you can't select 'none' and something else. I've just had a look and we've seen that error 23 times in the past 6 and a bit months which is pretty low. We are adding a new page with this pattern again so will be keeping an eye on the errors for this page and push to add a js feature. It's worth noting that our events vs unique events (meaning one checkbox being clicked more than once) is for the most case almost identical, meaning very few people are changing their mind once selected. So from our perspective it seems like having no client side javascript is working fine and server side validation is sufficient for when js isn't available. |
I'd suggest an error message something like: "You cannot select 'None of these' and other options" |
@joelanman Yeh, we currently have |
GOVUK (specifically @alex-ju ) have added this as a component in their own component library: alphagov/govuk_publishing_components#1478 . Can be previewed here: https://components.publishing.service.gov.uk/component-guide/checkboxes/checkbox_with_exclusive_item |
We'll need to think about conditional reveals when we do this – at the minute the logic for checkboxes assumes that we only need to sync the conditional reveal state for the checkbox that was clicked: govuk-frontend/src/govuk/components/checkboxes/checkboxes.js Lines 68 to 77 in 6e3a992
We'll also need to think about scope – do we scope to the immediate module, or make it act like a radio button and deselect any checkboxes with the same |
We added something for this in my service. More abstractly it creates 'mutually exclusive' groups - which get defined using data attributes on each checkbox. When a checkbox is checked, checkboxes in groups other than the current one get unchecked. The idea for this came from someone on the cross gov slack - but I don't remember who suggested it (they were doing similar). This generically supports where you might have more than one group. eg:
|
example from the census Alt textDo any of the following people also live at [address] on Sunday 21 March 2021?Who to include Family members and partners Housemates, tenants or lodgers People who usually live outside the UK who are staying in the UK for 3 months or more People temporarily away People staying temporarily who usually live in the UK but do not have another UK address Or, None of these apply, I am the only person who usually lives here |
What
Add guidance and possibly code to checkboxes to allow a 'None of these'
Why
We previously had this guidance in Dropbox Paper. The alternative is the user selects no checkboxes and clicks continue, which is an implicit answer. This is arguably less clear than an explicit answer, and there is a risk the user clicked continue accidentally.
The text was updated successfully, but these errors were encountered: