alphagov / govuk-frontend

GOV.UK Frontend contains the code you need to start building a user interface for government platforms and services.
https://frontend.design-system.service.gov.uk/
MIT License
1.18k stars 325 forks source link

Confused by the documentation for radios 'conditional' #1903

Closed joelanman closed 1 year ago

joelanman commented 4 years ago

I was trying to use the conditional option on radios.

I saw that the example used

conditional:{
    html:"<p> ...

I didn't need html, just a sentence so I thought I could use text instead of html as you can in other places in Frontend. However, I tried it and it didn't work - there's no text option here.

When I re-read the docs, I misread and thought the 'conditional' option, being a string, could just accept text.

However, I misread it, that doesn't work - the docs actually say:

conditional | string | If true, content provided will be revealed when the item is checked.

But I don't think this is correct? In the examples, conditional is not a string, it's an object with only one property - html

I wonder if this might be better as two options:

conditionalHTML and conditionalText

This would avoid another object, and be more consistent with the use of HTML and text elsewhere?

vanitabarrett commented 4 years ago

@joelanman Can you provide a link to that in the docs, as that looks like it needs correcting? It should read:

conditional | boolean | If true, content provided will be revealed when the item is checked.
conditional.html | string | Provide content for the conditional reveal.

(which I can see on https://design-system.service.gov.uk/components/checkboxes/)

Good point about being able to provide a text option though, that definitely seems to better match what we do elsewhere.

joelanman commented 4 years ago

It was radios I was looking at:

https://design-system.service.gov.uk/components/radios/

I would say even boolean is a bit confusing, as the examples don't use a boolean, they use an object

36degrees commented 4 years ago

For now we've agreed just to remove the conditional entry from the macro options for radios and checkboxes, which will make it consistent to the way the accordion works and is documented (apart from not supporting conditional.text).

mogusbi-motech commented 3 years ago

The documentation around this is still a bit off as it still suggests setting conditional with a text value would work, which it definitely doesn't judging by the code below:

https://github.com/alphagov/govuk-frontend/blob/master/src/govuk/components/radios/template.njk#L14-L19

Documentation reference: https://design-system.service.gov.uk/components/radios/

image

EoinShaughnessy commented 3 years ago

The macro options for radios and checkboxes still display the conditional parameter. Do we need to remove these instances?

joelanman commented 2 years ago

just come across this again in my work - conditional is still listed as a string option, and as boolean in checkboxes, both should probably be removed

joelanman commented 1 year ago

thanks!