-
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
Allow an optional hint for each radio and checkbox item #846
Conversation
bcfe773
to
0732870
Compare
0732870
to
8a81d6c
Compare
ce28732
to
a94f25f
Compare
a94f25f
to
c1c7797
Compare
7cebdcb
to
100797e
Compare
100797e
to
6735171
Compare
6735171
to
e59e1d9
Compare
e59e1d9
to
592d564
Compare
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.
Looking good – a few minor comments. Most of the comments I made on the checkboxes component also apply to the radios component.
- name: gateway | ||
id: government-gateway | ||
value: gov-gateway | ||
html: <b>Sign in with Government Gateway</b> |
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.
Can we remove the <b>
styling from this and use text so that the example reflects how it'll look 'by default'?
@@ -10,6 +10,7 @@ | |||
@include govuk-exports("govuk/component/checkboxes") { | |||
$govuk-checkboxes-size: govuk-spacing(7); | |||
$govuk-checkboxes-label-padding-left-right: govuk-spacing(3); | |||
$govuk-checkboxes-hint-padding-left-right: $govuk-checkboxes-label-padding-left-right; |
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.
Do we need this, or can we just reuse $govuk-checkboxes-label-padding-left-right
? Are there valid use cases where we're not going to want these to be the same?
@@ -48,18 +48,30 @@ | |||
{% set id = item.id if item.id else idPrefix + "-" + loop.index %} | |||
{% set name = item.name if item.name else params.name %} | |||
{% set conditionalId = "conditional-" + id %} | |||
{% set isItemHint = true if item.hint.text or item.hint.html %} |
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.
What about hasHint
for this variable? I find isItemHint
confusing because it suggests that the item is a hint.
@@ -255,6 +255,36 @@ describe('Checkboxes', () => { | |||
}) | |||
}) | |||
|
|||
it('render hint text', () => { | |||
const $ = render('checkboxes', { |
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'd make this as short as possible to make it clear exactly what it is we're testing in this component - there's a lot going on in this test which isn't actually required for the test to pass. I also don't think there's a need to use 'realistic' examples here, they'll only go out of date.
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 figure checking for input and hint relationship is correct so that it gets announced might be worth testing.
I could just test that it renders, but that not that useful.
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.
It's definitely useful to test that, but there's still a lot going on here for one test:
- You could take out a lot of the lines here (for example the entire first
item
) and the test would still pass, which makes it harder for others coming in to try and understand what's actually being tested. - There are three assertions being made, two of which aren't covered by the test description. If this test were to fail because the
aria-describedby
isn't what we expect, the description doesn't help you to understand why it's failing.
If you look at e.g. https://github.com/alphagov/govuk-frontend/blob/master/src/components/input/template.test.js#L85-L115:
- there's only one assertion per test
- the description of each test describes the assertion that's being made
- we're asserting on the behaviour we actually care about – we don't actually care what the
id
oraria-describedby
values are – as long as the id is included inaria-describedby
. For example, if we added another element which we wanted to add toaria-describedby
then this test as written would break (incorrectly) and we'd have to come back and fix it. - there's very little you could delete from each test without breaking it, so it's clear what the test is doing.
Does that make sense?
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.
yep. i've updated the tests
592d564
to
554d071
Compare
5c39317
to
bad3253
Compare
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.
Looking good – a few minor things it'd be good to address.
- name: gateway | ||
id: government-gateway | ||
value: gov-gateway | ||
html: Sign in with Government Gateway |
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.
Should be text
- name: verify | ||
id: govuk-verify | ||
value: gov-verify | ||
html: Sign in with GOV.UK Verify |
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.
Should be text
src/components/radios/radios.yaml
Outdated
isPageHeading: true | ||
items: | ||
- value: gateway | ||
html: Sign in with Government Gateway |
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.
Should be text
src/components/radios/radios.yaml
Outdated
hint: | ||
text: You'll have a user ID if you've registered for Self Assessment or filed a tax return online before. | ||
- value: verify | ||
html: Sign in with GOV.UK Verify |
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.
Should be text
describe('when they include a hint', () => { | ||
it('it renders the hint text', () => { | ||
const $ = render('radios', { | ||
idPrefix: 'gov', |
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.
Is this required (in all three tests)?
bad3253
to
6ca9f25
Compare
updated |
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.
Looks good. Left a couple of small comments.
Tested in the following:
✅Chrome 67 on Mac
✅ Firefox 61 on Mac
✅ Safari 11.1 on Mac
✅ IE8 - IE11 on Win 7
✅ Chrome, FF on Galaxy S9
✅ Samsung Internet on Galaxy S8
✅ Chrome, Safari on iPhone 6
✅ iOS VoiceOver on Safari and iPhone 7
✅Jaws 16, 17, 18 on IE11
✅NVDA on Firefox
@@ -48,18 +48,30 @@ | |||
{% set id = item.id if item.id else idPrefix + "-" + loop.index %} | |||
{% set name = item.name if item.name else params.name %} | |||
{% set conditionalId = "conditional-" + id %} | |||
{% set hasHint = true if item.hint.text or item.hint.html %} |
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.
itemHasHint
might be slightly more explanatory.
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.
We don't use the item prefix for anything else in this block (e.g. name
, not itemName
) – do we think this is different?
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.
We use itemHintId
below it. But it's not a strongly held view - itemHasHint
just feels like it would make it clearer that the hint is for the item, not the component.
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.
Whatever we do, it'd be good to be consistent within this block – id, name and conditionalId aren't prefixed. If we think it's useful to have that prefix, we should do it for all of them.
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.
we have itemHintId
because we already have hintId
, the whole group's hint
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.
In that case they should probably all be prefixed. It isn't clear from the context why itemHintId
is named differently (to avoid clash with the group level hint) 🤔
value: gov-verify | ||
html: Sign in with GOV.UK Verify | ||
hint: | ||
text: You’ll have an account if you’ve already proved your identity with either Barclays, CitizenSafe, Digidentity, Experian, Post Office, Royal Mail or SecureIdentity. |
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.
Nit: this could go very quickly out of date.
6ca9f25
to
39182d8
Compare
I was hoping to have this in the last release. Do you think it will be in v1.2.0? |
@alex-ju we can try to do a quicker release if you're blocked by this for sure. |
not a blocker, and even if so I can reproduce it before the release/updating to the latest version, but it's definitely something that we need short-term. |
39182d8
to
ff7542a
Compare
CHANGELOG.md
Outdated
@@ -75,7 +81,7 @@ | |||
`headingLevel: <number>` parameter. Default is `2`. | |||
([PR #853](https://github.com/alphagov/govuk-frontend/pull/853)) | |||
|
|||
- Update date input component | |||
- Update date input component |
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.
can we keep this in here?
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.
Yeah, we need to figure out how to get our editors stripping whitespace consistently, but that should not block this PR
ff7542a
to
61faf13
Compare
- Update template to allow for hint component to be passed - Add example to yaml - Add test to check that hint is present - Update table of arguments with the new option - Regenerate README
- Update template to allow for hint component to be passed - Add example to yaml - Add test to check that hint is present - Update table of arguments with the new option - Regenerate README
61faf13
to
68f8bce
Compare
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.
💯
It's currently it is not possible to use hints in items as seen in https://www.gov.uk/log-in-file-self-assessment-tax-return/sign-in/prove-identity in Nunjucks macros
This work allows for optional hint object to be passed to each item that outputs a hint component. Id of that hint component is set as
aria-describedby
on radio/checkbox into so that it's read by AT.Direct urls:
https://govuk-frontend-review-pr-846.herokuapp.com/components/checkboxes/with-hints-on-items/preview
https://govuk-frontend-review-pr-846.herokuapp.com/components/radios/with-hints-on-items/preview
Browser tests:
Chrome 67 and Safari 11.1.1 ✅
IE8 ✅
IE11 ✅
Safari 9.3 iOS and Samsung Internet browser ✅
AT tests:
VoiceOver on maOSJAWS 16, 17, 18 in IE11: Hint read
NVDA: Hint read
Talkback on Android: Hint read
Voiceover on iOS: Hint read
This fixes: #768