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

Allow an optional hint for each radio and checkbox item #846

Merged
merged 3 commits into from
Jul 25, 2018

Conversation

kr8n3r
Copy link

@kr8n3r kr8n3r commented Jun 29, 2018

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.

  • 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

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 ✅ safari chrome
IE8 ✅ ie8
IE11 ✅ ie11
Safari 9.3 iOS and Samsung Internet browser ✅ safari9-3 samsung-internet

AT tests: VoiceOver on maOS voiceover

JAWS 16, 17, 18 in IE11: Hint read
NVDA: Hint read
Talkback on Android: Hint read
Voiceover on iOS: Hint read

This fixes: #768

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-846 June 29, 2018 07:14 Inactive
@kr8n3r kr8n3r force-pushed the hint-in-radios-and-checkboxes branch from bcfe773 to 0732870 Compare June 29, 2018 07:33
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-846 June 29, 2018 07:33 Inactive
@kr8n3r kr8n3r force-pushed the hint-in-radios-and-checkboxes branch from 0732870 to 8a81d6c Compare June 29, 2018 07:37
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-846 June 29, 2018 07:38 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-846 June 29, 2018 11:01 Inactive
@kr8n3r kr8n3r force-pushed the hint-in-radios-and-checkboxes branch from ce28732 to a94f25f Compare June 29, 2018 11:03
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-846 June 29, 2018 11:03 Inactive
@kr8n3r kr8n3r force-pushed the hint-in-radios-and-checkboxes branch from a94f25f to c1c7797 Compare June 29, 2018 11:05
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-846 June 29, 2018 11:05 Inactive
@kr8n3r kr8n3r changed the title WIP: Allow for optional hint each radio and checkbox item WIP: Allow for optional hint for each radio and checkbox item Jun 29, 2018
@kr8n3r kr8n3r changed the title WIP: Allow for optional hint for each radio and checkbox item Allow for optional hint for each radio and checkbox item Jul 2, 2018
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-846 July 2, 2018 08:27 Inactive
@36degrees 36degrees requested a review from dashouse July 2, 2018 08:46
@kr8n3r kr8n3r force-pushed the hint-in-radios-and-checkboxes branch from 7cebdcb to 100797e Compare July 2, 2018 08:55
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-846 July 2, 2018 08:55 Inactive
@kr8n3r kr8n3r force-pushed the hint-in-radios-and-checkboxes branch from 100797e to 6735171 Compare July 2, 2018 14:32
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-846 July 2, 2018 14:32 Inactive
@kr8n3r kr8n3r added feature request User requests a new feature enhancement and removed feature request User requests a new feature labels Jul 2, 2018
@kr8n3r kr8n3r force-pushed the hint-in-radios-and-checkboxes branch from 6735171 to e59e1d9 Compare July 3, 2018 08:52
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-846 July 3, 2018 08:52 Inactive
@kr8n3r kr8n3r changed the title Allow for optional hint for each radio and checkbox item Allow an optional hint for each radio and checkbox item Jul 4, 2018
@kr8n3r kr8n3r added this to the v1.1.0 milestone Jul 4, 2018
@kr8n3r kr8n3r force-pushed the hint-in-radios-and-checkboxes branch from e59e1d9 to 592d564 Compare July 4, 2018 13:56
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-846 July 4, 2018 13:56 Inactive
Copy link
Contributor

@36degrees 36degrees left a 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>
Copy link
Contributor

@36degrees 36degrees Jul 5, 2018

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;
Copy link
Contributor

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 %}
Copy link
Contributor

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', {
Copy link
Contributor

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.

Copy link
Author

@kr8n3r kr8n3r Jul 6, 2018

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.

Copy link
Contributor

@36degrees 36degrees Jul 10, 2018

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 or aria-describedby values are – as long as the id is included in aria-describedby. For example, if we added another element which we wanted to add to aria-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?

Copy link
Author

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

@kr8n3r kr8n3r force-pushed the hint-in-radios-and-checkboxes branch from 592d564 to 554d071 Compare July 5, 2018 19:12
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-846 July 6, 2018 08:07 Inactive
@kr8n3r kr8n3r force-pushed the hint-in-radios-and-checkboxes branch from 5c39317 to bad3253 Compare July 10, 2018 15:55
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-846 July 10, 2018 15:55 Inactive
Copy link
Contributor

@36degrees 36degrees left a 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
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be text

isPageHeading: true
items:
- value: gateway
html: Sign in with Government Gateway
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be text

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
Copy link
Contributor

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',
Copy link
Contributor

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)?

@kr8n3r kr8n3r force-pushed the hint-in-radios-and-checkboxes branch from bad3253 to 6ca9f25 Compare July 11, 2018 13:49
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-846 July 11, 2018 13:49 Inactive
@kr8n3r
Copy link
Author

kr8n3r commented Jul 11, 2018

updated

Copy link
Member

@hannalaakso hannalaakso left a 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 %}
Copy link
Member

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.

Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Author

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

Copy link
Member

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.
Copy link
Member

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.

@kr8n3r kr8n3r removed this from the v1.1.0 milestone Jul 13, 2018
@NickColley NickColley added feature request User requests a new feature and removed enhancement labels Jul 13, 2018
@kr8n3r kr8n3r force-pushed the hint-in-radios-and-checkboxes branch from 6ca9f25 to 39182d8 Compare July 13, 2018 18:43
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-846 July 13, 2018 18:43 Inactive
@alex-ju
Copy link
Contributor

alex-ju commented Jul 16, 2018

I was hoping to have this in the last release. Do you think it will be in v1.2.0?

@NickColley
Copy link
Contributor

@alex-ju we can try to do a quicker release if you're blocked by this for sure.

@alex-ju
Copy link
Contributor

alex-ju commented Jul 16, 2018

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.

@kr8n3r kr8n3r force-pushed the hint-in-radios-and-checkboxes branch from 39182d8 to ff7542a Compare July 19, 2018 08:19
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
Copy link
Author

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?

Copy link
Contributor

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

@kr8n3r kr8n3r force-pushed the hint-in-radios-and-checkboxes branch from ff7542a to 61faf13 Compare July 19, 2018 10:39
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-846 July 24, 2018 08:30 Inactive
igloosi added 3 commits July 25, 2018 08:47
- 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
Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@kr8n3r kr8n3r added this to the [NEXT] milestone Jul 25, 2018
@kr8n3r kr8n3r merged commit d155120 into master Jul 25, 2018
@kr8n3r kr8n3r deleted the hint-in-radios-and-checkboxes branch July 25, 2018 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request User requests a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GOV.UK Radios (Checkboxes) Items do not support Hints
6 participants