From 778030739d2b7f26f1520d401054e0c57d55e250 Mon Sep 17 00:00:00 2001 From: eshamard Date: Tue, 22 Oct 2024 10:59:28 +0200 Subject: [PATCH] fix(RHINENG-8416): Do not open menu on checkbox click --- .../src/BulkSelect/BulkSelect.test.js | 8 +++-- .../components/src/BulkSelect/BulkSelect.tsx | 31 +++++++------------ 2 files changed, 17 insertions(+), 22 deletions(-) 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` : ''} + )}