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 attributes on checkboxes/radios #942

Merged
merged 1 commit into from
Aug 7, 2018
Merged

Allow attributes on checkboxes/radios #942

merged 1 commit into from
Aug 7, 2018

Conversation

colinrotherham
Copy link
Contributor

Unlike other form controls, the checkbox/radio templates only allow attributes on the wrapping container markup.

Services like ours add data attributes to some checkboxes:

items:
  - value: yes
    text: Yes
    attributes:
      data-example: '123'
  - value: no
    text: No
    attributes:
      data-example: '456'

Following the same pattern as the other input, textarea and select, details templates etc, the attributes are appended like this:

<input ... value="yes" data-example="123">
<input ... value="no" data-example="456">

Hopefully this pull request will help other teams too 😊

Copy link
Contributor

@NickColley NickColley left a comment

Choose a reason for hiding this comment

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

Hey Colin,

Thanks for this!

The general approach seems great, as the addition to items mirrors the attributes approach we use for components.

There are some more house style changes required before we can merge this, let me know if you'd prefer me to do this for you.

This Pull Request will also need to be reviewed and agreed by another member of the team.

@@ -28,6 +28,13 @@

([PR #N](https://github.com/alphagov/govuk-frontend/pull/N))

- Allow attributes on checkboxes/radios
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is adding a new feature this changelog entry should be under the feature title.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@NickColley No problem, moved it to "New features"

@@ -43,6 +43,32 @@ examples:
value: irish
text: Irish

- name: with attributes on items
Copy link
Contributor

Choose a reason for hiding this comment

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

Not documented, we are trying to only add .yaml examples where we cannot write a unit test for it.

In this case could you remove this example and test that this functionality works by adding a test in checkboxes/template.test.js please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@NickColley Ah that's fine, makes sense. Added two new tests!

@colinrotherham
Copy link
Contributor Author

colinrotherham commented Aug 6, 2018

@NickColley I've made those two review changes.

Tests all passing 👍

@colinrotherham
Copy link
Contributor Author

Updated checkbox/radio readme to document new items.{}.attributes

Copy link
Contributor

@NickColley NickColley left a comment

Choose a reason for hiding this comment

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

Excellent work thanks Colin 👍

We'll need another review from another member of the team.

@kr8n3r kr8n3r added this to the [NEXT] milestone Aug 7, 2018
@dashouse
Copy link

dashouse commented Aug 7, 2018

Looks good to me 👍

@NickColley NickColley merged commit b86ad2e into alphagov:master Aug 7, 2018
@colinrotherham colinrotherham deleted the input-attributes branch August 7, 2018 15:36
colinrotherham added a commit to dwp/pyca-prototype that referenced this pull request Aug 8, 2018
colinrotherham added a commit to dwp/pyca-prototype that referenced this pull request Aug 9, 2018
colinrotherham added a commit to dwp/pyca-prototype that referenced this pull request Aug 9, 2018
colinrotherham added a commit to dwp/pyca-prototype that referenced this pull request Aug 9, 2018
colinrotherham added a commit to dwp/pyca-prototype that referenced this pull request Aug 9, 2018
colinrotherham added a commit to dwp/pyca-prototype that referenced this pull request Aug 10, 2018
colinrotherham added a commit to dwp/pyca-prototype that referenced this pull request Aug 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment