flowbite-react icon indicating copy to clipboard operation
flowbite-react copied to clipboard

`ButtonGroup` ignores nested `Button`s

Open tulup-conner opened this issue 3 years ago • 0 comments

Describe the bug ButtonGroup prop-drills its immediate children, assuming they are Buttons. Thus, something like this:

<Button.Group>
  <div className="w-10">
    <Button color="gray">Profile</Button>
  </div>
  <div className="w-10">
    <Button color="gray">Settings</Button>
  </div>
  <div className="w-10">
    <Button color="gray">Messages</Button>
  </div>
</Button.Group>

Does not work like expected.

To Reproduce Steps to reproduce the behavior:

  1. Add the above snippet to a flowbite-react project
  2. Observe that the buttons are not grouped together, since props (namely, positionInGroup) aren't being passed

Expected behavior We should be able to put any HTML inside a Button.Group. Obviously, as long as there's a few Buttons in there.

This wasn't necessary before FlowbiteTheme, but now, in order to customize Buttons, you sometimes need to wrap them in a <div>. That behavior should be supported by ButtonGroups.

We can switch to context, but I don't think there's any way to keep track of the order of the buttons by doing that. So what might be necessary is to prop-drill until we find Buttons, specifically, rather than regular HTML elements.

tulup-conner avatar Jul 31 '22 21:07 tulup-conner