Skip to content

Commit dcd784a

Browse files
feat(BulkSelect): expose menuToggle props
1 parent 459c09e commit dcd784a

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,33 @@ describe('BulkSelect component', () => {
4040
expect(dropdownList).toBeInTheDocument();
4141
expect(dropdownList).toHaveClass('pf-v6-c-menu__list');
4242
});
43+
44+
test('should render with menuToggleProps', () => {
45+
render(
46+
<BulkSelect
47+
canSelectAll
48+
pageCount={5}
49+
totalCount={10}
50+
selectedCount={2}
51+
pageSelected={false}
52+
pagePartiallySelected={true}
53+
onSelect={() => null}
54+
menuToggleProps={{ isDisabled: true, className: 'custom-menu-toggle' }}
55+
/>
56+
);
57+
58+
const toggleButton = screen.getByLabelText('Bulk select toggle');
59+
expect(toggleButton).toBeInTheDocument();
60+
61+
// Confirm the split button toggle is disabled
62+
expect(toggleButton).toBeDisabled();
63+
64+
// Confirm the split button toggle receives the correct PatternFly class
65+
expect(toggleButton).toHaveClass('pf-v6-c-menu-toggle__button');
66+
67+
// Confirm the split button toggle wrapper receives the custom class
68+
const toggleWrapper = toggleButton.parentElement;
69+
expect(toggleWrapper).toBeInTheDocument();
70+
expect(toggleWrapper).toHaveClass('custom-menu-toggle');
71+
});
4372
});

packages/module/src/BulkSelect/BulkSelect.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import {
99
MenuToggle,
1010
MenuToggleCheckbox,
1111
MenuToggleCheckboxProps,
12-
MenuToggleElement
12+
MenuToggleElement,
13+
MenuToggleProps
1314
} from '@patternfly/react-core';
1415

1516
export const BulkSelectValue = {
@@ -47,6 +48,8 @@ export interface BulkSelectProps extends Omit<DropdownProps, 'toggle' | 'onSelec
4748
menuToggleCheckboxProps?: Omit<MenuToggleCheckboxProps, 'onChange' | 'isChecked' | 'instance' | 'ref'>;
4849
/** Additional props for DropdownList */
4950
dropdownListProps?: Omit<DropdownListProps, 'children'>;
51+
/** Additional props for MenuToggleProps */
52+
menuToggleProps?: Omit<MenuToggleProps, 'children' | 'splitButtonItems' | 'ref' | 'isExpanded' | 'onClick'>;
5053
}
5154

5255
export const BulkSelect: FC<BulkSelectProps> = ({
@@ -61,6 +64,7 @@ export const BulkSelect: FC<BulkSelectProps> = ({
6164
onSelect,
6265
menuToggleCheckboxProps,
6366
dropdownListProps,
67+
menuToggleProps,
6468
...props
6569
}: BulkSelectProps) => {
6670
const [ isOpen, setOpen ] = useState(false);
@@ -116,7 +120,7 @@ export const BulkSelect: FC<BulkSelectProps> = ({
116120
aria-label={`Select ${allOption}`}
117121
isChecked={
118122
(isDataPaginated && pagePartiallySelected) ||
119-
(!isDataPaginated && selectedCount > 0 && selectedCount < totalCount)
123+
(!isDataPaginated && selectedCount > 0 && selectedCount < totalCount)
120124
? null
121125
: pageSelected || (selectedCount === totalCount && totalCount > 0)
122126
}
@@ -129,6 +133,7 @@ export const BulkSelect: FC<BulkSelectProps> = ({
129133
</span>
130134
) : null
131135
]}
136+
{...menuToggleProps}
132137
/>
133138
)}
134139
{...props}

0 commit comments

Comments
 (0)