Skip to content

Commit

Permalink
Add missing spellcheck param to character count
Browse files Browse the repository at this point in the history
We added a new spellcheck param to the textarea component in #1859

However, we forgot to add the param to the character count component, which meant it couldn't be passed through to the textarea. This adds the missing param.
  • Loading branch information
Vanita Barrett committed Jul 17, 2020
1 parent ce8e223 commit 2ee4810
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
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,
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

0 comments on commit 2ee4810

Please sign in to comment.