diff --git a/packages/components/src/BulkSelect/BulkSelect.test.js b/packages/components/src/BulkSelect/BulkSelect.test.js index 8e6da1263..0db1e846f 100644 --- a/packages/components/src/BulkSelect/BulkSelect.test.js +++ b/packages/components/src/BulkSelect/BulkSelect.test.js @@ -141,10 +141,12 @@ describe('BulkSelect', () => { await act(async () => { await userEvent.click(screen.getByRole('checkbox', { name: 'Select all' })); }); - act(() => { - userEvent.click(screen.getByRole('button', { expanded: true })); - }); expect(onSelect).toHaveBeenCalled(); + + await act(async () => { + await userEvent.click(screen.getByRole('button')); + }); + expect(screen.getByRole('button')).toHaveAttribute('aria-expanded', 'true'); expect(otherAction).not.toHaveBeenCalled(); }); diff --git a/packages/components/src/BulkSelect/BulkSelect.tsx b/packages/components/src/BulkSelect/BulkSelect.tsx index 62e834529..f0012c3c4 100644 --- a/packages/components/src/BulkSelect/BulkSelect.tsx +++ b/packages/components/src/BulkSelect/BulkSelect.tsx @@ -83,25 +83,18 @@ const BulkSelect: React.FunctionComponent = ({ toggleProps?.children ) : ( - {hasError ? ( - - ) : ( - - {count ? `${count} selected` : ''} - - )} + { + setIsOpen(false); + onSelect?.(checked, event); + }} + isChecked={checked} + ouiaId={checkboxOuiaId ?? 'BulkSelectCheckbox'} + > + {!hasError && count ? `${count} selected` : ''} + )}