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

Remove unnecessary use of aria-hidden in the character count #2479

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 0 additions & 4 deletions src/govuk/components/character-count/character-count.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,8 @@ CharacterCount.prototype.updateCountMessage = function () {
var thresholdValue = maxLength * thresholdPercent / 100
if (thresholdValue > currentLength) {
countMessage.classList.add('govuk-character-count__message--disabled')
// Ensure threshold is hidden for users of assistive technologies
countMessage.setAttribute('aria-hidden', true)
} else {
countMessage.classList.remove('govuk-character-count__message--disabled')
// Ensure threshold is visible for users of assistive technologies
countMessage.removeAttribute('aria-hidden')
}

// Update styles
Expand Down
8 changes: 0 additions & 8 deletions src/govuk/components/character-count/character-count.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,13 @@ describe('Character count', () => {
it('does not show the limit until the threshold is reached', async () => {
const visibility = await page.$eval('.govuk-character-count__message', el => window.getComputedStyle(el).visibility)
expect(visibility).toEqual('hidden')

// Ensure threshold is hidden for users of assistive technologies
const ariaHidden = await page.$eval('.govuk-character-count__message', el => el.getAttribute('aria-hidden'))
expect(ariaHidden).toEqual('true')
})

it('becomes visible once the threshold is reached', async () => {
await page.type('.govuk-js-character-count', 'A'.repeat(8))

const visibility = await page.$eval('.govuk-character-count__message', el => window.getComputedStyle(el).visibility)
expect(visibility).toEqual('visible')

// Ensure threshold is visible for users of assistive technologies
const ariaHidden = await page.$eval('.govuk-character-count__message', el => el.getAttribute('aria-hidden'))
expect(ariaHidden).toBeFalsy()
})
})

Expand Down