Skip to content

Commit

Permalink
Merge pull request #2086 from LightOfHeaven1994/RHINENG-8416
Browse files Browse the repository at this point in the history
fix(RHINENG-8416): Do not open menu on checkbox click
  • Loading branch information
Hyperkid123 authored Oct 25, 2024
2 parents 1fbd347 + e9c0db3 commit 1cebfbb
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 1cebfbb

Please sign in to comment.