Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ButtonGroup variant outlined always has primary color borders on hover #29219

Closed
2 tasks done
mattixittam opened this issue Oct 22, 2021 · 3 comments · Fixed by #29487
Closed
2 tasks done

ButtonGroup variant outlined always has primary color borders on hover #29219

mattixittam opened this issue Oct 22, 2021 · 3 comments · Fixed by #29487
Assignees
Labels
bug 🐛 Something doesn't work component: ButtonGroup The React component.

Comments

@mattixittam
Copy link

mattixittam commented Oct 22, 2021

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

When a buttongroup button with variant outlined and a different color than primary set on the individual button is hovered over, the border is palette.primary.main instead of palette[color].x.

Expected Behavior 🤔

The color prop should also influence the border color on hover. This works when color is set on the ButtonGroup, but not when it is set on the individual buttons.

To be clear: my intent is to be able to set two different colors for the buttons in a buttongroup.

Possibly this is not an intended way of working (having different colors per button), but we have several buttons from our material-ui v4 codebase which worked fine but started misbehaving in v5.

Steps to Reproduce 🕹

https://codesandbox.io/s/mui-buttongroup-color-bug-t37rv?file=/src/Demo.tsx

Your Environment 🌎

`npx @mui/envinfo`

Browser: Chrome 95

No env info needed, codesandbox shows the bug.

@mattixittam mattixittam added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Oct 22, 2021
@mnajdova mnajdova added bug 🐛 Something doesn't work component: ButtonGroup The React component. and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 25, 2021
@mnajdova
Copy link
Member

Thanks for the report. Would be interesting to see if this can be solved as part of #28645 @ZeeshanTamboli FYI

@ZeeshanTamboli
Copy link
Member

ZeeshanTamboli commented Oct 26, 2021

@mnajdova I think we can solve it separately. I looked into it. After inspecting in dev tools, I think the ButtonGroup hover styles has high specificity than Button if they are composed together.
https://github.com/mui-org/material-ui/blob/b6cdaaf1a7f60de9ed66a491b7477fad19429905/packages/mui-material/src/ButtonGroup/ButtonGroup.js#L153-L157

Button hovering border-color style individually without ButtonGroup works.

How can we make sure that child elements (Button) hover border-color style have high priority over parent (ButtonGroup)?

@mnajdova
Copy link
Member

mnajdova commented Nov 2, 2021

@ZeeshanTamboli if we are now providing the color via context, does the ButtonGroup even needs to set the borderColor? We can still set the borederRadius

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: ButtonGroup The React component.
Projects
None yet
3 participants