Skip to content

Commit

Permalink
fix: Color & square props are ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
Merkur39 committed Mar 11, 2024
1 parent 16f2097 commit c37ad2f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion react/Alert/index.jsx
Expand Up @@ -52,6 +52,7 @@ const Alert = forwardRef(
square,
action,
variant,
style,
children,
...props
},
Expand All @@ -65,10 +66,22 @@ const Alert = forwardRef(
const iconSize = icon?.props?.size || DEFAULT_ICON_SIZE
const styles = useStyles({ iconSize, block })

/*
When this component is the child of Snackbar, MUI injects a `style` prop
(https://github.com/mui/material-ui/blob/bda562b435a70e3e8f6d7fb04581c6816a5ba0c7/packages/material-ui/src/Snackbar/Snackbar.js#L235
=>
https://github.com/mui/material-ui/blob/1e80616d3dde536227af56d49f91b28f830bd33c/packages/mui-material/src/Grow/Grow.js #L193), our styles are overwritten.
*/
const computedStyles = {
backgroundColor: color,
borderRadius: square && 0,
...style
}

return (
<MuiAlert
ref={ref}
style={{ backgroundColor: color, borderRadius: square && 0 }}
style={computedStyles}
className={cx(
className,
`cozyStyles-${severity}-${variant}`,
Expand Down

0 comments on commit c37ad2f

Please sign in to comment.