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

fix: do not add aria-describedby to hidden inputs #12496

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions js/foundation.abide.js
Expand Up @@ -328,6 +328,7 @@ class Abide extends Plugin {
}

addA11yErrorDescribe($el, $error) {
if ($el.attr('type') === 'hidden') return;
if (typeof $el.attr('aria-describedby') !== 'undefined') return;

// Set [aria-describedby] on the input toward the first form error if it is not set
Expand Down
13 changes: 13 additions & 0 deletions test/javascript/components/abide.js
Expand Up @@ -157,6 +157,19 @@ describe('Abide', function() {
$html.find('input').should.not.have.attr('aria-describedby', 'test-error');
});

it('does not add [aria-describedby] to the field if the input is hidden', function() {
$html = $(`
<form data-abide>
<input type="hidden" id="test-input">
<span class="form-error is-visible" id="test-error">Form error</span>
</form>
`).appendTo('body');
plugin = new Foundation.Abide($html, {});
plugin.addA11yAttributes($html.find('input'));

$html.find('input').should.not.have.attr('aria-describedby', 'test-error');
});

it('adds [aria-describedby] to the field if the form error is shown after a validation error', function() {
$html = $(`
<form data-abide>
Expand Down