diff --git a/packages/components/src/BulkSelect/BulkSelect.test.js b/packages/components/src/BulkSelect/BulkSelect.test.js index 754f185f9..8e6da1263 100644 --- a/packages/components/src/BulkSelect/BulkSelect.test.js +++ b/packages/components/src/BulkSelect/BulkSelect.test.js @@ -162,5 +162,23 @@ describe('BulkSelect', () => { ); expect(screen.getByRole('button', { expanded: false })).toBeDisabled(); }); + + it('should not override children passed in via toggleProps', () => { + render( + + ); + + expect(screen.getByRole('button', { name: '10 selected' })).toBeInTheDocument(); + }); }); }); diff --git a/packages/components/src/BulkSelect/BulkSelect.tsx b/packages/components/src/BulkSelect/BulkSelect.tsx index af4f0c064..62e834529 100644 --- a/packages/components/src/BulkSelect/BulkSelect.tsx +++ b/packages/components/src/BulkSelect/BulkSelect.tsx @@ -79,27 +79,31 @@ const BulkSelect: React.FunctionComponent = ({ onClick={() => setIsOpen((prev) => !prev)} data-ouia-component-id={dropdownOuiaId ?? 'BulkSelect'} > - - {hasError ? ( - - ) : ( - - {count ? `${count} selected` : ''} - - )} - + {toggleProps?.children ? ( + toggleProps?.children + ) : ( + + {hasError ? ( + + ) : ( + + {count ? `${count} selected` : ''} + + )} + + )} )} isOpen={isOpen}