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

Add missing spellcheck param to character count #1869

Merged
merged 2 commits into from
Jul 17, 2020
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ We darkened `govuk-colour("dark-grey")` to improve the readability of hint text.

#### Add spellcheck parameter to input and textarea components

Optional parameter added to the input and textarea components to enable or disable the spellcheck attribute
Optional parameter added to the input, textarea and character count components to enable or disable the spellcheck attribute

([PR #1859](https://github.com/alphagov/govuk-frontend/pull/1859))
([PR #1869](https://github.com/alphagov/govuk-frontend/pull/1869))
vanitabarrett marked this conversation as resolved.
Show resolved Hide resolved

### Fixes

Expand Down
4 changes: 4 additions & 0 deletions src/govuk/components/character-count/character-count.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ params:
type: object
required: false
description: HTML attributes (for example data attributes) to add to the textarea.
- name: spellcheck
type: boolean
required: false
description: Optional field to enable or disable the spellcheck attribute on the character count.
- name: countMessage
type: object
required: false
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 @@
name: params.name,
describedBy: params.id + '-info',
rows: params.rows,
spellcheck: params.spellcheck,
vanitabarrett marked this conversation as resolved.
Show resolved Hide resolved
value: params.value,
formGroup: params.formGroup,
classes: 'govuk-js-character-count' + (' govuk-textarea--error' if params.errorMessage) + (' ' + params.classes if params.classes),
Expand Down
31 changes: 31 additions & 0 deletions src/govuk/components/character-count/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ describe('Character count', () => {
const $countMessage = $('.govuk-character-count__message')
expect($countMessage.hasClass('app-custom-count-message')).toBeTruthy()
})

it('renders with aria live set to polite', () => {
const $ = render('character-count', {})

Expand All @@ -145,6 +146,36 @@ describe('Character count', () => {
})
})

describe('when it has the spellcheck attribute', () => {
it('renders the textarea with spellcheck attribute set to true', () => {
const $ = render('character-count', {
spellcheck: true
})

const $component = $('.govuk-character-count .govuk-textarea')
expect($component.attr('spellcheck')).toEqual('true')
})

it('renders the textarea with spellcheck attribute set to false', () => {
const $ = render('character-count', {
name: 'my-char-count-name',
spellcheck: false
})

const $component = $('.govuk-character-count .govuk-textarea')
expect($component.attr('spellcheck')).toEqual('false')
})

it('renders the textarea without spellcheck attribute by default', () => {
const $ = render('character-count', {
name: 'my-char-count-name'
})

const $component = $('.govuk-character-count .govuk-textarea')
expect($component.attr('spellcheck')).toBeUndefined()
})
})

describe('when it includes a hint', () => {
it('renders with hint', () => {
const $ = render('character-count', {
Expand Down