Skip to content

Commit 1c9449f

Browse files
nicolethoenclaude
andauthored
feat(BulkSelect): add dropdownListProps for greater control (#820)
Add a new dropdownListProps prop to the BulkSelect component to allow users to pass additional props to the DropdownList component, similar to the existing menuToggleCheckboxProps. This provides greater customization and control over the dropdown list portion of the component. This feature was requested in issue #819 to enable more granular control over the BulkSelect component's dropdown behavior and styling. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 288388e commit 1c9449f

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

packages/module/src/BulkSelect/BulkSelect.test.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { render } from '@testing-library/react';
1+
import { render, screen } from '@testing-library/react';
2+
import userEvent from '@testing-library/user-event';
23
import BulkSelect from './BulkSelect';
34

45
describe('BulkSelect component', () => {
@@ -14,4 +15,29 @@ describe('BulkSelect component', () => {
1415
onSelect={() => null}
1516
/>)).toMatchSnapshot();
1617
});
18+
19+
test('should render with dropdownListProps', async () => {
20+
const user = userEvent.setup();
21+
render(
22+
<BulkSelect
23+
canSelectAll
24+
pageCount={5}
25+
totalCount={10}
26+
selectedCount={2}
27+
pageSelected={false}
28+
pagePartiallySelected={true}
29+
onSelect={() => null}
30+
dropdownListProps={{ className: 'custom-dropdown-list' }}
31+
/>
32+
);
33+
34+
// Open the dropdown by clicking the toggle button
35+
const toggleButton = screen.getByLabelText('Bulk select toggle');
36+
await user.click(toggleButton);
37+
38+
// Now the dropdown list should be visible with the custom class
39+
const dropdownList = document.querySelector('.custom-dropdown-list');
40+
expect(dropdownList).toBeInTheDocument();
41+
expect(dropdownList).toHaveClass('pf-v6-c-menu__list');
42+
});
1743
});

packages/module/src/BulkSelect/BulkSelect.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
Dropdown,
55
DropdownItem,
66
DropdownList,
7+
DropdownListProps,
78
DropdownProps,
89
MenuToggle,
910
MenuToggleCheckbox,
@@ -44,6 +45,8 @@ export interface BulkSelectProps extends Omit<DropdownProps, 'toggle' | 'onSelec
4445
ouiaId?: string;
4546
/** Additional props for MenuToggleCheckbox */
4647
menuToggleCheckboxProps?: Omit<MenuToggleCheckboxProps, 'onChange' | 'isChecked' | 'instance' | 'ref'>;
48+
/** Additional props for DropdownList */
49+
dropdownListProps?: Omit<DropdownListProps, 'children'>;
4750
}
4851

4952
export const BulkSelect: FC<BulkSelectProps> = ({
@@ -57,6 +60,7 @@ export const BulkSelect: FC<BulkSelectProps> = ({
5760
ouiaId = 'BulkSelect',
5861
onSelect,
5962
menuToggleCheckboxProps,
63+
dropdownListProps,
6064
...props
6165
}: BulkSelectProps) => {
6266
const [ isOpen, setOpen ] = useState(false);
@@ -129,7 +133,7 @@ export const BulkSelect: FC<BulkSelectProps> = ({
129133
)}
130134
{...props}
131135
>
132-
<DropdownList>{splitButtonDropdownItems}</DropdownList>
136+
<DropdownList {...dropdownListProps}>{splitButtonDropdownItems}</DropdownList>
133137
</Dropdown>)
134138
);
135139
};

0 commit comments

Comments
 (0)