Skip to content

Commit 6d16c55

Browse files
renovate[bot]Stefan3002
authored andcommitted
fix: a11y bug: aria-expanded not supported here
1 parent 1e63d1c commit 6d16c55

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useEffectEvent, useRef, useState } from "react";
1+
import React, { useEffect, useRef, useState } from "react";
22
import Chip from "../../Chip";
33
import { overflowingChipsCount, isChipInArray } from "../utils";
44
import { highlightSubString } from "../../../utils";
@@ -45,11 +45,11 @@ const FilterPanelSection = ({
4545

4646
// If the offsetTop is more than double height of a single chip, consider it
4747
// overflowing
48-
const updateFlowCount = useEffectEvent(() => {
48+
const updateFlowCount = function () {
4949
const chips = chipWrapper?.current?.querySelectorAll(".p-chip");
5050
const overflowCount = overflowingChipsCount(chips, 2);
5151
setOverflowCounter(overflowCount);
52-
});
52+
};
5353

5454
// Check if search term characters matches any characters in panel heading
5555
const searchTermInHeading = highlightSubString(heading, searchTerm).match;
@@ -104,11 +104,7 @@ const FilterPanelSection = ({
104104
}}
105105
/>
106106
)}
107-
<div
108-
className="p-filter-panel-section__chips"
109-
aria-expanded={expanded}
110-
ref={chipWrapper}
111-
>
107+
<div className="p-filter-panel-section__chips" ref={chipWrapper}>
112108
{chips?.map((chip) => {
113109
// If search term has been added to input, only matching chips
114110
// should display

src/components/SearchAndFilter/SearchAndFilter.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,13 @@ const SearchAndFilter = ({
236236
<div
237237
className="p-search-and-filter"
238238
ref={searchAndFilterRef}
239-
onClick={() => filterPanelHidden && setFilterPanelHidden(false)}
239+
onClick={() => {
240+
return filterPanelHidden && setFilterPanelHidden(false);
241+
}}
240242
{...props}
241243
>
242244
<div
243245
className="p-search-and-filter__search-container"
244-
aria-expanded={searchBoxExpanded}
245246
data-active={searchContainerActive || searchData.length === 0}
246247
data-empty={searchData.length <= 0}
247248
ref={searchContainerRef}
@@ -284,6 +285,11 @@ const SearchAndFilter = ({
284285
{searchData.length ? Label.AddFilter : Label.SearchAndFilter}
285286
</label>
286287
<input
288+
role="combobox"
289+
aria-expanded={!filterPanelHidden}
290+
aria-controls={
291+
!filterPanelHidden ? "search-and-filter-panel" : undefined
292+
}
287293
autoComplete="off"
288294
className="p-search-and-filter__input"
289295
id="search-and-filter-input"
@@ -313,6 +319,7 @@ const SearchAndFilter = ({
313319
<div
314320
className="p-search-and-filter__panel"
315321
aria-hidden={filterPanelHidden}
322+
id="search-and-filter-panel"
316323
ref={panel}
317324
style={{ maxHeight, minHeight: "5rem", overflowX: "auto" }}
318325
>

0 commit comments

Comments
 (0)