Skip to content

Commit

Permalink
fix styling issue when using Button component with variant contained
Browse files Browse the repository at this point in the history
Signed-off-by: Emma Indal <emma.indahl@gmail.com>
  • Loading branch information
emmaindal committed Oct 6, 2021
1 parent 427209c commit a05a774
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/core-components/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,20 @@ export type ButtonProps = MaterialButtonProps &
*/
declare function ButtonType(props: ButtonProps): JSX.Element;

const ActualButton = React.forwardRef<any, ButtonProps>((props, ref) => (
<MaterialButton ref={ref} component={Link} {...props} />
)) as { (props: ButtonProps): JSX.Element };
const ActualButton = React.forwardRef<any, ButtonProps>((props, ref) => {
/**
This temporarily fixes a bug in material-ui where the color of the Link
overrides the color of the button
https://github.com/mui-org/material-ui/issues/28852
*/
let color;
if (props.variant === 'contained') {
color = 'white';
}
return (
<MaterialButton ref={ref} component={Link} style={{ color }} {...props} />
);
}) as { (props: ButtonProps): JSX.Element };

// TODO(Rugvip): We use this as a workaround to make the exported type be a
// function, which makes our API reference docs much nicer.
Expand Down

0 comments on commit a05a774

Please sign in to comment.