TablePanel: Fix table cells overflowing when there are multiple data links (#65711)

* Fix table cells overflowing when there are multiple data links
This commit is contained in:
Oscar Kilhed
2023-04-03 12:34:29 +02:00
committed by GitHub
parent d96b0a71d3
commit 06ea490cc2
2 changed files with 9 additions and 6 deletions
@@ -7,7 +7,7 @@ import { TableCellBackgroundDisplayMode, TableCellOptions } from '@grafana/schem
import { useStyles2 } from '../../themes'; import { useStyles2 } from '../../themes';
import { getCellLinks, getTextColorForAlphaBackground } from '../../utils'; import { getCellLinks, getTextColorForAlphaBackground } from '../../utils';
import { Button, clearLinkButtonStyles } from '../Button'; import { clearLinkButtonStyles } from '../Button';
import { DataLinksContextMenu } from '../DataLinks/DataLinksContextMenu'; import { DataLinksContextMenu } from '../DataLinks/DataLinksContextMenu';
import { CellActions } from './CellActions'; import { CellActions } from './CellActions';
@@ -42,15 +42,17 @@ export const DefaultCell = (props: TableCellProps) => {
{hasLinks && ( {hasLinks && (
<DataLinksContextMenu links={() => getCellLinks(field, row) || []}> <DataLinksContextMenu links={() => getCellLinks(field, row) || []}>
{(api) => { {(api) => {
const content = <div className={getLinkStyle(tableStyles, cellOptions, api.targetClassName)}>{value}</div>;
if (api.openMenu) { if (api.openMenu) {
return ( return (
<Button className={cx(clearButtonStyle)} onClick={api.openMenu}> <button
{content} className={cx(clearButtonStyle, getLinkStyle(tableStyles, cellOptions, api.targetClassName))}
</Button> onClick={api.openMenu}
>
{value}
</button>
); );
} else { } else {
return content; return <div className={getLinkStyle(tableStyles, cellOptions, api.targetClassName)}>{value}</div>;
} }
}} }}
</DataLinksContextMenu> </DataLinksContextMenu>
@@ -175,6 +175,7 @@ export function useTableStyles(theme: GrafanaTheme2, cellHeightOption: TableCell
font-weight: ${theme.typography.fontWeightMedium}; font-weight: ${theme.typography.fontWeightMedium};
&:hover { &:hover {
text-decoration: underline; text-decoration: underline;
color: ${theme.colors.text.link};
} }
`, `,
cellLinkForColoredCell: css` cellLinkForColoredCell: css`