diff --git a/src/app/base/components/FilterAccordion/FilterAccordion.test.tsx b/src/app/base/components/FilterAccordion/FilterAccordion.test.tsx index bec4de03d3..a65426e009 100644 --- a/src/app/base/components/FilterAccordion/FilterAccordion.test.tsx +++ b/src/app/base/components/FilterAccordion/FilterAccordion.test.tsx @@ -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( + null} + toggleFilter={FilterMachines.toggleFilter} + /> + ); + + expect(screen.getByRole("button", { name: Labels.Toggle })).toBeDisabled(); + }); }); diff --git a/src/app/base/components/FilterAccordion/FilterAccordion.tsx b/src/app/base/components/FilterAccordion/FilterAccordion.tsx index 5afbd3ad4d..14c9ebc8da 100644 --- a/src/app/base/components/FilterAccordion/FilterAccordion.tsx +++ b/src/app/base/components/FilterAccordion/FilterAccordion.tsx @@ -196,7 +196,7 @@ const FilterAccordion = ({ hasToggleIcon position="left" toggleClassName="filter-accordion__toggle" - toggleDisabled={disabled} + toggleDisabled={disabled || items?.length === 0} toggleLabel={Labels.Toggle} >