Skip to content

Commit

Permalink
fix: disable filter accordion for no items (#5223)
Browse files Browse the repository at this point in the history
  • Loading branch information
petermakowski authored Nov 24, 2023
1 parent ee016c4 commit 0a1a355
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/app/base/components/FilterAccordion/FilterAccordion.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,23 @@ describe("FilterAccordion", () => {
screen.queryByRole("tab", { name: filterNames.get("link_speeds") })
).not.toBeInTheDocument();
});

it("is disabled if there are no items to display", async () => {
render(
<FilterAccordion
filterNames={filterNames}
filterOrder={filterOrder}
filterString=""
filtersToString={FilterMachines.filtersToString}
getCurrentFilters={FilterMachines.getCurrentFilters}
getValue={getValue}
isFilterActive={FilterMachines.isFilterActive}
items={[]}
onUpdateFilterString={() => null}
toggleFilter={FilterMachines.toggleFilter}
/>
);

expect(screen.getByRole("button", { name: Labels.Toggle })).toBeDisabled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ const FilterAccordion = <I, PK extends keyof I>({
hasToggleIcon
position="left"
toggleClassName="filter-accordion__toggle"
toggleDisabled={disabled}
toggleDisabled={disabled || items?.length === 0}
toggleLabel={Labels.Toggle}
>
<Accordion
Expand Down

0 comments on commit 0a1a355

Please sign in to comment.