mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-01 14:41:25 -04:00
Fix aria on collapsed checkboxes fieldset
The fieldset that wraps the collapsible checkboxes has an aria-describedby to make the summary its accessible description. This needs to point to the id of the summary but the summary didn't have one. These changes add the id and fix a fixture in the tests for this module.
This commit is contained in:
@@ -20,12 +20,14 @@
|
||||
}[field] || `No ${field}s`)
|
||||
};
|
||||
Summary.prototype.addContent = function() {
|
||||
const $hint = this.module.$formGroup.find('.govuk-hint');
|
||||
this.$text = $(`<p class="selection-summary__text" />`);
|
||||
|
||||
if (this.fieldLabel === 'folder') { this.$text.addClass('selection-summary__text--folders'); }
|
||||
|
||||
this.$el.attr('id', $hint.attr('id'));
|
||||
this.$el.append(this.$text);
|
||||
this.module.$formGroup.find('.govuk-hint').remove();
|
||||
$hint.remove();
|
||||
};
|
||||
Summary.prototype.update = function(selection) {
|
||||
let template;
|
||||
|
||||
@@ -42,10 +42,10 @@ describe('Collapsible fieldset', () => {
|
||||
document.body.innerHTML =
|
||||
`<div class="selection-wrapper" data-module="collapsible-checkboxes" data-field-label="folder">
|
||||
<div class="govuk-form-group">
|
||||
<fieldset class="govuk-fieldset" id="folder_permissions">
|
||||
<fieldset class="govuk-fieldset" id="folder_permissions" aria-describedby="users_with_permission-hint">
|
||||
<legend class="govuk-fieldset__legend govuk-fieldset__legend--s">
|
||||
Folders this team member can see
|
||||
<span class="govuk-hint">
|
||||
<span class="govuk-hint" id="users_with_permission-hint">
|
||||
<div class="selection-summary" role="region" aria-live="polite"></div>
|
||||
</span>
|
||||
</legend>
|
||||
@@ -144,12 +144,29 @@ describe('Collapsible fieldset', () => {
|
||||
|
||||
});
|
||||
|
||||
test("removes the hint", () => {
|
||||
test("the hint is removed", () => {
|
||||
|
||||
expect(document.querySelector('.govuk-hint')).toBeNull();
|
||||
|
||||
});
|
||||
|
||||
describe("the live region that was inside the hint", () => {
|
||||
|
||||
test("is moved above the fieldset", () => {
|
||||
|
||||
expect(fieldset.previousElementSibling.matches('.selection-summary')).toBe(true);
|
||||
|
||||
});
|
||||
|
||||
test("has an id matching the aria-describedby on the fieldset", () => {
|
||||
|
||||
const fieldsetDescribedby = fieldset.getAttribute('aria-describedby');
|
||||
expect(fieldset.previousElementSibling.getAttribute('id')).toEqual(fieldsetDescribedby);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test('has the right summary text when started with no checkboxes selected', () => {
|
||||
|
||||
Reference in New Issue
Block a user