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

Include formGroup on character count and pass through to textarea to … #1553

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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