Skip to content

Commit

Permalink
fix: tooltip arrow regression after last scroll max size feat (#2935)
Browse files Browse the repository at this point in the history
Fixes an issue where the `HtmlTooltip` arrow would no longer work after
a regression included with #2891

Also adds the arrow prop to most usages of the tooltip to keep
consistency.
  • Loading branch information
nunogois committed Jan 19, 2023
1 parent aa96d9b commit 08c1123
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
14 changes: 11 additions & 3 deletions frontend/src/component/common/HtmlTooltip/HtmlTooltip.tsx
@@ -1,9 +1,18 @@
import { styled, Tooltip, tooltipClasses, TooltipProps } from '@mui/material';
import { SpacingArgument } from '@mui/system/createTheme/createSpacing';

const StyledHtmlTooltipBody = styled('div')(({ theme }) => ({
overflow: 'auto',
padding: theme.spacing(1, 1.5),
}));

const StyledHtmlTooltip = styled(
({ className, maxWidth, maxHeight, ...props }: IHtmlTooltipProps) => (
<Tooltip {...props} classes={{ popper: className }} />
<Tooltip
{...props}
title={<StyledHtmlTooltipBody>{props.title}</StyledHtmlTooltipBody>}
classes={{ popper: className }}
/>
),
{
shouldForwardProp: prop => prop !== 'maxWidth' && prop !== 'maxHeight',
Expand All @@ -15,15 +24,14 @@ const StyledHtmlTooltip = styled(
display: 'flex',
flexDirection: 'column',
backgroundColor: theme.palette.background.paper,
padding: theme.spacing(1, 1.5),
padding: 0,
borderRadius: theme.shape.borderRadiusMedium,
boxShadow: theme.shadows[2],
color: theme.palette.text.primary,
fontWeight: theme.fontWeight.medium,
maxWidth: 'inherit',
border: `1px solid ${theme.palette.lightBorder}`,
maxHeight: maxHeight || theme.spacing(37.5),
overflow: 'auto',
},
[`& .${tooltipClasses.arrow}`]: {
'&:before': {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/component/common/TooltipLink/TooltipLink.tsx
@@ -1,5 +1,5 @@
import { ReactNode } from 'react';
import { Link, LinkProps, styled, TooltipProps } from '@mui/material';
import { Link, LinkProps, styled } from '@mui/material';
import { HtmlTooltip, IHtmlTooltipProps } from '../HtmlTooltip/HtmlTooltip';

const StyledLink = styled(Link, {
Expand All @@ -26,7 +26,7 @@ export const TooltipLink = ({
children,
...props
}: ITooltipLinkProps) => (
<HtmlTooltip title={tooltip} {...tooltipProps}>
<HtmlTooltip title={tooltip} {...tooltipProps} arrow>
<StyledLink highlighted={highlighted} {...props}>
{children}
</StyledLink>
Expand Down
Expand Up @@ -46,7 +46,7 @@ export const EnvironmentNameCell = ({
condition={!environment.enabled}
show={
<HtmlTooltip
sx={{ maxWidth: '270px' }}
maxWidth="270px"
title={
<>
<StyledTooltipTitle>
Expand All @@ -60,6 +60,7 @@ export const EnvironmentNameCell = ({
</>
}
describeChild
arrow
>
<StyledBadge color="neutral">Deprecated</StyledBadge>
</HtmlTooltip>
Expand Down

0 comments on commit 08c1123

Please sign in to comment.