Skip to content

Commit

Permalink
[Radio] Skip default hover style when disableRipple is set (#34902)
Browse files Browse the repository at this point in the history
  • Loading branch information
VinceCYLiao committed Oct 31, 2022
1 parent 9e41c71 commit d89bb89
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ const BpCheckedIcon = styled(BpIcon)({
function BpRadio(props) {
return (
<Radio
sx={{
'&:hover': {
bgcolor: 'transparent',
},
}}
disableRipple
color="default"
checkedIcon={<BpCheckedIcon />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ const BpCheckedIcon = styled(BpIcon)({
function BpRadio(props: RadioProps) {
return (
<Radio
sx={{
'&:hover': {
bgcolor: 'transparent',
},
}}
disableRipple
color="default"
checkedIcon={<BpCheckedIcon />}
Expand Down
36 changes: 19 additions & 17 deletions packages/mui-material/src/Radio/Radio.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,26 @@ const RadioRoot = styled(SwitchBase, {
},
})(({ theme, ownerState }) => ({
color: (theme.vars || theme).palette.text.secondary,
'&:hover': {
backgroundColor: theme.vars
? `rgba(${
ownerState.color === 'default'
? theme.vars.palette.action.activeChannel
: theme.vars.palette[ownerState.color].mainChannel
} / ${theme.vars.palette.action.hoverOpacity})`
: alpha(
ownerState.color === 'default'
? theme.palette.action.active
: theme.palette[ownerState.color].main,
theme.palette.action.hoverOpacity,
),
// Reset on touch devices, it doesn't add specificity
'@media (hover: none)': {
backgroundColor: 'transparent',
...(!ownerState.disableRipple && {
'&:hover': {
backgroundColor: theme.vars
? `rgba(${
ownerState.color === 'default'
? theme.vars.palette.action.activeChannel
: theme.vars.palette[ownerState.color].mainChannel
} / ${theme.vars.palette.action.hoverOpacity})`
: alpha(
ownerState.color === 'default'
? theme.palette.action.active
: theme.palette[ownerState.color].main,
theme.palette.action.hoverOpacity,
),
// Reset on touch devices, it doesn't add specificity
'@media (hover: none)': {
backgroundColor: 'transparent',
},
},
},
}),
...(ownerState.color !== 'default' && {
[`&.${radioClasses.checked}`]: {
color: (theme.vars || theme).palette[ownerState.color].main,
Expand Down

0 comments on commit d89bb89

Please sign in to comment.