Skip to content

Commit

Permalink
Merge pull request #1553 from LBHELewis/feature/include-form-group-on…
Browse files Browse the repository at this point in the history
…-character-count-component

Include formGroup on character count and pass through to textarea to …
  • Loading branch information
NickColley authored Sep 6, 2019
2 parents 9953dbe + 2d64599 commit 50036b5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

### New features

#### Add formGroup parameter to character count component

- [Pull request #1553: Include formGroup on character count and pass through to textarea to allow class to be added to character count form group](https://github.com/alphagov/govuk-frontend/pull/1553)

### Fixes

- [Pull request #1548: Fix fieldset legend text clipping when using a custom or fallback font](https://github.com/alphagov/govuk-frontend/pull/1548).
Expand Down
10 changes: 10 additions & 0 deletions src/govuk/components/character-count/character-count.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ params:
required: false
description: Options for the errorMessage component (e.g. text).
isComponent: true
- name: formGroup
type: object
required: false
description: Options for the form-group wrapper
params:
- name: classes
type: string
required: false
description: Classes to add to the form group (e.g. to show error state for the whole group)
- name: classes
type: string
required: false
Expand All @@ -51,6 +60,7 @@ params:
required: false
description: HTML attributes (for example data attributes) to add to the textarea.


examples:
- name: default
data:
Expand Down
1 change: 1 addition & 0 deletions src/govuk/components/character-count/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
describedBy: params.id + '-info',
rows: params.rows,
value: params.value,
formGroup: params.formGroup,
classes: 'govuk-js-character-count ' + (' govuk-textarea--error' if params.errorMessage) + (params.classes if params.classes),
label: {
html: params.label.html,
Expand Down
11 changes: 11 additions & 0 deletions src/govuk/components/character-count/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ describe('Character count', () => {
const $component = $('.govuk-js-character-count')
expect($component.attr('data-attribute')).toEqual('my data value')
})

it('renders with formGroup', () => {
const $ = render('character-count', {
formGroup: {
classes: 'app-character-count--custom-modifier'
}
})

const $component = $('.govuk-form-group')
expect($component.hasClass('app-character-count--custom-modifier')).toBeTruthy()
})
})

describe('when it includes a hint', () => {
Expand Down

0 comments on commit 50036b5

Please sign in to comment.