Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion packages/module/src/BulkSelect/BulkSelect.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { render } from '@testing-library/react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import BulkSelect from './BulkSelect';

describe('BulkSelect component', () => {
Expand All @@ -14,4 +15,29 @@ describe('BulkSelect component', () => {
onSelect={() => null}
/>)).toMatchSnapshot();
});

test('should render with dropdownListProps', async () => {
const user = userEvent.setup();
render(
<BulkSelect
canSelectAll
pageCount={5}
totalCount={10}
selectedCount={2}
pageSelected={false}
pagePartiallySelected={true}
onSelect={() => null}
dropdownListProps={{ className: 'custom-dropdown-list' }}
/>
);

// Open the dropdown by clicking the toggle button
const toggleButton = screen.getByLabelText('Bulk select toggle');
await user.click(toggleButton);

// Now the dropdown list should be visible with the custom class
const dropdownList = document.querySelector('.custom-dropdown-list');
expect(dropdownList).toBeInTheDocument();
expect(dropdownList).toHaveClass('pf-v6-c-menu__list');
});
});
6 changes: 5 additions & 1 deletion packages/module/src/BulkSelect/BulkSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Dropdown,
DropdownItem,
DropdownList,
DropdownListProps,
DropdownProps,
MenuToggle,
MenuToggleCheckbox,
Expand Down Expand Up @@ -44,6 +45,8 @@ export interface BulkSelectProps extends Omit<DropdownProps, 'toggle' | 'onSelec
ouiaId?: string;
/** Additional props for MenuToggleCheckbox */
menuToggleCheckboxProps?: Omit<MenuToggleCheckboxProps, 'onChange' | 'isChecked' | 'instance' | 'ref'>;
/** Additional props for DropdownList */
dropdownListProps?: Omit<DropdownListProps, 'children'>;
}

export const BulkSelect: FC<BulkSelectProps> = ({
Expand All @@ -57,6 +60,7 @@ export const BulkSelect: FC<BulkSelectProps> = ({
ouiaId = 'BulkSelect',
onSelect,
menuToggleCheckboxProps,
dropdownListProps,
...props
}: BulkSelectProps) => {
const [ isOpen, setOpen ] = useState(false);
Expand Down Expand Up @@ -129,7 +133,7 @@ export const BulkSelect: FC<BulkSelectProps> = ({
)}
{...props}
>
<DropdownList>{splitButtonDropdownItems}</DropdownList>
<DropdownList {...dropdownListProps}>{splitButtonDropdownItems}</DropdownList>
</Dropdown>)
);
};
Expand Down
Loading