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

Character count count message is not associated with textarea #1106

Closed
36degrees opened this issue Dec 21, 2018 · 2 comments
Closed

Character count count message is not associated with textarea #1106

36degrees opened this issue Dec 21, 2018 · 2 comments
Assignees
Labels
accessibility character count 🕔 hours A well understood issue which we expect to take less than a day to resolve.

Comments

@36degrees
Copy link
Contributor

The character count info message is (I believe) meant to be associated with the textarea using aria-describedby. However, this association is only made if there is no existing error message:

var countMessage = document.getElementById(elementId + '-info')
// If there is no existing info count message we add one right after the field
if (elementId && !countMessage) {
countElement.insertAdjacentHTML('afterend', '<span id="' + elementId + '-info" class="govuk-hint govuk-character-count__message" aria-live="polite"></span>')
this.describedBy = countElement.getAttribute('aria-describedby')
this.describedByInfo = this.describedBy + ' ' + elementId + '-info'
countElement.setAttribute('aria-describedby', this.describedByInfo)
countMessage = document.getElementById(elementId + '-info')
} else {
// If there is an existing info count message we move it right after the field
countElement.insertAdjacentElement('afterend', countMessage)
}

We always provide an existing info message as of 7b534bf:

<span id="{{ params.id }}-info" class="govuk-hint govuk-character-count__message" aria-live="polite">
You can enter up to {{ params.maxlength or params.maxwords }} {{'words' if params.maxwords else 'characters' }}
</span>

This means that the association will never be created.

From testing with Voiceover / Safari, the limit is still announced when it changes (because of the aria-live on the message), but it is no longer announced when focussing the field which I believe it should be.

@alex-ju
Copy link
Contributor

alex-ju commented Dec 28, 2018

Steven Proctor reported this a while ago and, at least at that point, an update on the textarea component was needed to be able pass the described by attribute to the element.

@36degrees
Copy link
Contributor Author

This was fixed by #1347

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility character count 🕔 hours A well understood issue which we expect to take less than a day to resolve.
Projects
Development

Successfully merging a pull request may close this issue.

4 participants