diff --git a/packages/grafana-ui/src/components/Button/Button.tsx b/packages/grafana-ui/src/components/Button/Button.tsx index ae3a9032956..711b42dcd74 100644 --- a/packages/grafana-ui/src/components/Button/Button.tsx +++ b/packages/grafana-ui/src/components/Button/Button.tsx @@ -311,3 +311,18 @@ export const clearButtonStyles = (theme: GrafanaTheme2) => { padding: 0; `; }; + +export const clearLinkButtonStyles = (theme: GrafanaTheme2) => { + return css` + background: transparent; + border: none; + padding: 0; + font-family: inherit; + color: inherit; + height: 100%; + &:hover { + background: transparent; + color: inherit; + } + `; +}; diff --git a/packages/grafana-ui/src/components/Table/DefaultCell.tsx b/packages/grafana-ui/src/components/Table/DefaultCell.tsx index 026cfb16e8a..7f134b3056a 100644 --- a/packages/grafana-ui/src/components/Table/DefaultCell.tsx +++ b/packages/grafana-ui/src/components/Table/DefaultCell.tsx @@ -5,7 +5,9 @@ import tinycolor from 'tinycolor2'; import { DisplayValue, formattedValueToString } from '@grafana/data'; import { TableCellBackgroundDisplayMode, TableCellOptions } from '@grafana/schema'; +import { useStyles2 } from '../../themes'; import { getCellLinks, getTextColorForAlphaBackground } from '../../utils'; +import { Button, clearLinkButtonStyles } from '../Button'; import { DataLinksContextMenu } from '../DataLinks/DataLinksContextMenu'; import { CellActions } from './CellActions'; @@ -31,6 +33,7 @@ export const DefaultCell: FC = (props) => { const cellOptions = getCellOptions(field); const cellStyle = getCellStyle(tableStyles, cellOptions, displayValue, inspectEnabled); const hasLinks = Boolean(getCellLinks(field, row)?.length); + const clearButtonStyle = useStyles2(clearLinkButtonStyles); return (
@@ -39,11 +42,16 @@ export const DefaultCell: FC = (props) => { {hasLinks && ( getCellLinks(field, row) || []}> {(api) => { - return ( -
- {value} -
- ); + const content =
{value}
; + if (api.openMenu) { + return ( + + ); + } else { + return content; + } }}
)} diff --git a/packages/grafana-ui/src/components/Table/FilterPopup.tsx b/packages/grafana-ui/src/components/Table/FilterPopup.tsx index 7261e66ee96..3498b0b3700 100644 --- a/packages/grafana-ui/src/components/Table/FilterPopup.tsx +++ b/packages/grafana-ui/src/components/Table/FilterPopup.tsx @@ -50,6 +50,8 @@ export const FilterPopup: FC = ({ column: { preFilteredRows, filterValue, return ( + {/* This is just blocking click events from bubbeling and should not have a keyboard interaction. */} + {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}
diff --git a/packages/grafana-ui/src/components/Table/ImageCell.tsx b/packages/grafana-ui/src/components/Table/ImageCell.tsx index c1e8b2ee2f1..9dffa16b88e 100644 --- a/packages/grafana-ui/src/components/Table/ImageCell.tsx +++ b/packages/grafana-ui/src/components/Table/ImageCell.tsx @@ -1,7 +1,9 @@ import { cx } from '@emotion/css'; import React, { FC } from 'react'; +import { useStyles2 } from '../../themes'; import { getCellLinks } from '../../utils'; +import { Button, clearLinkButtonStyles } from '../Button'; import { DataLinksContextMenu } from '../DataLinks/DataLinksContextMenu'; import { TableCellProps } from './types'; @@ -12,6 +14,7 @@ export const ImageCell: FC = (props) => { const displayValue = field.display!(cell.value); const hasLinks = Boolean(getCellLinks(field, row)?.length); + const clearButtonStyle = useStyles2(clearLinkButtonStyles); return (
@@ -19,11 +22,16 @@ export const ImageCell: FC = (props) => { {hasLinks && ( getCellLinks(field, row) || []}> {(api) => { - return ( -
- -
- ); + const img = ; + if (api.openMenu) { + return ( + + ); + } else { + return img; + } }}
)} diff --git a/packages/grafana-ui/src/components/Table/JSONViewCell.tsx b/packages/grafana-ui/src/components/Table/JSONViewCell.tsx index 70c73fce64e..68483d62e19 100644 --- a/packages/grafana-ui/src/components/Table/JSONViewCell.tsx +++ b/packages/grafana-ui/src/components/Table/JSONViewCell.tsx @@ -2,7 +2,9 @@ import { css, cx } from '@emotion/css'; import { isString } from 'lodash'; import React from 'react'; +import { useStyles2 } from '../../themes'; import { getCellLinks } from '../../utils'; +import { Button, clearLinkButtonStyles } from '../Button'; import { DataLinksContextMenu } from '../DataLinks/DataLinksContextMenu'; import { CellActions } from './CellActions'; @@ -28,6 +30,7 @@ export function JSONViewCell(props: TableCellProps): JSX.Element { } const hasLinks = Boolean(getCellLinks(field, row)?.length); + const clearButtonStyle = useStyles2(clearLinkButtonStyles); return (
@@ -36,11 +39,15 @@ export function JSONViewCell(props: TableCellProps): JSX.Element { {hasLinks && ( getCellLinks(field, row) || []}> {(api) => { - return ( -
- {displayValue} -
- ); + if (api.openMenu) { + return ( + + ); + } else { + return <>{displayValue}; + } }}
)}