Skip to content

Commit

Permalink
Revert "fix: do not add aria-expanded=true to facet search (#1954)"
Browse files Browse the repository at this point in the history
This reverts commit 6bd7f6c.
  • Loading branch information
louis-bompart committed Nov 7, 2023
1 parent 6bd7f6c commit 24e5459
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ui/Facet/FacetSearchElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ export class FacetSearchElement {
this.combobox.setAttribute('role', 'combobox');
this.combobox.setAttribute('aria-owns', this.facetSearchId);
this.input.setAttribute('aria-controls', this.facetSearchId);
this.input.setAttribute('aria-expanded', 'true');
this.facetSearch.setExpandedFacetSearchAccessibilityAttributes(this.searchResults);
}

Expand All @@ -330,6 +331,7 @@ export class FacetSearchElement {
this.combobox.removeAttribute('aria-owns');
this.input.removeAttribute('aria-controls');
this.input.removeAttribute('aria-activedescendant');
this.input.setAttribute('aria-expanded', 'false');
this.facetSearch.setCollapsedFacetSearchAccessibilityAttributes();
}
}
12 changes: 12 additions & 0 deletions unitTests/ui/FacetSearchTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ export function FacetSearchTest() {
it('should give the input the aria-controls attribute', () => {
expect(facetSearch.facetSearchElement.input.getAttribute('aria-controls')).toEqual(facetSearchId);
});

it("should set aria-expanded to true on the input's element", () => {
expect(facetSearch.facetSearchElement.input.getAttribute('aria-expanded')).toEqual('true');
});
});

describe('when triggering a query', () => {
Expand Down Expand Up @@ -157,6 +161,10 @@ export function FacetSearchTest() {
it("should remove the input's aria-controls attribute", () => {
expect(facetSearch.facetSearchElement.input.getAttribute('aria-controls')).toBeNull();
});

it("should set aria-expanded to false on the input's element", () => {
expect(facetSearch.facetSearchElement.input.getAttribute('aria-expanded')).toEqual('false');
});
});
});

Expand All @@ -173,6 +181,10 @@ export function FacetSearchTest() {
done();
});

it("should set aria-expanded to true on the input's element", () => {
expect(facetSearch.facetSearchElement.input.getAttribute('aria-expanded')).toEqual('true');
});

it('should contain only a "no values found" element', () => {
expect(
$$(facetSearch.searchResults)
Expand Down

0 comments on commit 24e5459

Please sign in to comment.