Skip to content

Commit

Permalink
Add example for checkboxes with error message and hints on items
Browse files Browse the repository at this point in the history
The fieldset has the `aria-describedby` so we don’t need it on the input
  • Loading branch information
colinrotherham committed Apr 5, 2019
1 parent 86533e9 commit aa4358a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/components/checkboxes/checkboxes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,28 @@ examples:
- value: farm
text: Farm or agricultural waste

- name: with error message and hints on items
data:
name: waste
errorMessage:
text: Please select an option
fieldset:
legend:
text: Which types of waste do you transport regularly?
items:
- value: animal
text: Waste from animal carcasses
hint:
text: Nullam id dolor id nibh ultricies vehicula ut id elit.
- value: mines
text: Waste from mines or quarries
hint:
text: Nullam id dolor id nibh ultricies vehicula ut id elit.
- value: farm
text: Farm or agricultural waste
hint:
text: Nullam id dolor id nibh ultricies vehicula ut id elit.

- name: with very long option text
data:
name: waste
Expand Down
11 changes: 11 additions & 0 deletions src/components/checkboxes/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,17 @@ describe('Checkboxes', () => {
.toMatch(errorMessageId)
})

it('does not associate each input as "described by" the error message', () => {
const $ = render('checkboxes', examples['with error message and hints on items'])

const $inputs = $('input')

$inputs.each((i, input) => {
expect($(input).attr('aria-describedby'))
.toEqual(`waste-${(i + 1)}-item-hint`)
})
})

it('renders with a form group wrapper that has an error state', () => {
const $ = render('checkboxes', {
errorMessage: {
Expand Down

0 comments on commit aa4358a

Please sign in to comment.