Skip to content

Commit

Permalink
fix(RHINENG-8416): Do not open menu on checkbox click
Browse files Browse the repository at this point in the history
  • Loading branch information
LightOfHeaven1994 committed Oct 22, 2024
1 parent 6bbd0a0 commit 7780307
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
8 changes: 5 additions & 3 deletions packages/components/src/BulkSelect/BulkSelect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
31 changes: 12 additions & 19 deletions packages/components/src/BulkSelect/BulkSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,18 @@ const BulkSelect: React.FunctionComponent<BulkSelectProps> = ({
toggleProps?.children
) : (
<Fragment key="split-checkbox">
{hasError ? (
<MenuToggleCheckbox
id={id ? `${id}-toggle-checkbox` : 'toggle-checkbox'}
aria-label="Select all"
onChange={onSelect}
isChecked={checked}
ouiaId={checkboxOuiaId ?? 'BulkSelectCheckbox'}
/>
) : (
<MenuToggleCheckbox
id={id ? `${id}-toggle-checkbox` : 'toggle-checkbox'}
aria-label="Select all"
onChange={onSelect}
isChecked={checked}
ouiaId={checkboxOuiaId ?? 'BulkSelectCheckbox'}
>
{count ? `${count} selected` : ''}
</MenuToggleCheckbox>
)}
<MenuToggleCheckbox
id={id ? `${id}-toggle-checkbox` : 'toggle-checkbox'}
aria-label="Select all"
onChange={(checked, event) => {
setIsOpen(false);
onSelect?.(checked, event);
}}
isChecked={checked}
ouiaId={checkboxOuiaId ?? 'BulkSelectCheckbox'}
>
{!hasError && count ? `${count} selected` : ''}
</MenuToggleCheckbox>
</Fragment>
)}
</MenuToggle>
Expand Down

0 comments on commit 7780307

Please sign in to comment.