Skip to content

[ButtonGroup] Prevent sticky hover border on touch devices - #48993

Merged
silviuaavram merged 1 commit into
mui:masterfrom
petr-kratochvil:fix/buttongroup-hover
Aug 19, 2026
Merged

silviuaavram merged 1 commit into
mui:masterfrom
petr-kratochvil:fix/buttongroup-hover

Conversation

@petr-kratochvil

@petr-kratochvil petr-kratochvil commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Closes #48992

Summary

On touch devices, tapping a button inside an ButtonGroup with variant="outlined" leaves its right border (horizontal) or bottom border (vertical) permanently darkened, until another element is tapped.

ButtonGroup restores the divider border on hover:

[`& .${buttonGroupClasses.firstButton},& .${buttonGroupClasses.middleButton}`]: {
borderRightColor: 'transparent',
'&:hover': {
borderRightColor: 'currentColor',
},
},

Button already guards all of its own hover styles behind @media (hover: hover):

'@media (hover: hover)': {
'&:hover': {
'--variant-containedBg': (theme.vars || theme).palette[color].dark,

(So the sticky tap-hover is currently not applied to a Button at all.)

This PR applies the same @media (hover: hover) guard to ButtonGroup.

Technical detail

The ButtonGroup has a &:hover specification, which cancels the borderRightColor: 'transparent' (or borderBottomColor for vertical orientation). The rest of hover style is done in the Button.

  • Button does not do any hover for touch device
  • ButtonGroup still cancels the transparation of right/bottom border
  • => so it suddenly becomes visible and inconsistent on touch device.

Scope

Only the outlined variant has a border with a hover rule.

The remaining &:hover in

'&:hover': {
boxShadow: 'none',
},
is intentionally not touched.

@code-infra-dashboard

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-48993--material-ui.netlify.app/
QR code for https://deploy-preview-48993--material-ui.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/material 🔺+52B(+0.01%) 🔺+3B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@petr-kratochvil
petr-kratochvil marked this pull request as ready for review August 18, 2026 11:35
@zannager zannager added the component: ButtonGroup The React component. label Aug 18, 2026
@zannager
zannager requested a review from silviuaavram August 18, 2026 14:35

@silviuaavram silviuaavram left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for the contribution!

@silviuaavram
silviuaavram merged commit 7cb351c into mui:master Aug 19, 2026
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: ButtonGroup The React component.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ButtonGroup] Sticky hover leaves a darkened divider border after tapping on touch devices

3 participants