themesberg / flowbite-react

Official React components built for Flowbite and Tailwind CSS
https://flowbite-react.com
MIT License
1.78k stars 396 forks source link

Dynamically generated buttons within a button group are not properly styled. #1269

Closed lehelk closed 4 months ago

lehelk commented 5 months ago

Steps to reproduce

<div className='mb-4'>
  <ButtonGroup>
    <Button>Button 1</Button>
    <Button>Button 2</Button>
    <Button>Button 3</Button>
    <Button>Button 4</Button>
    <Button>Button 5</Button>
  </ButtonGroup>
</div>
<div className='mb-4'>
  <ButtonGroup>
    <Button>Button 1</Button>
    {[2, 3, 4].map(value => <Button key={value}>Button {value}</Button>)}
    <Button>Button 5</Button>
  </ButtonGroup>
</div>

Will have the following result:

Screenshot 2024-02-11 at 17 44 58

Current behavior

On the second line in the provided screenshot (where there are dynamically generated buttons) the 3rd button has rounded borders on the right hand side while the 5th button doesn't have rounded borders on the right hand side.

Expected behavior

On the second line in the provided screenshot (where there are dynamically generated buttons) the 3rd button shouldn't have any rounded borders while the 5th button should have rounded borders on the right hand side.

SutuSebastian commented 5 months ago

Known issue, it's because the Children.map() does not go deeper than one level, so the props are not injected in the dynamically generated buttons due to being an [] array instead of a ReactNode or JSX.Element.