diff --git a/.eslintrc b/.eslintrc index c44471d9560..9762e398bbb 100644 --- a/.eslintrc +++ b/.eslintrc @@ -75,7 +75,6 @@ // we should remove the corresponding line and fix them one by one // any marked "error" contain specific overrides we'll need to keep "jsx-a11y/click-events-have-key-events": "off", - "jsx-a11y/mouse-events-have-key-events": "off", "jsx-a11y/no-autofocus": [ "error", { diff --git a/packages/grafana-ui/src/components/VizLegend/VizLegend.tsx b/packages/grafana-ui/src/components/VizLegend/VizLegend.tsx index cff25cb0294..b3fadcbe6be 100644 --- a/packages/grafana-ui/src/components/VizLegend/VizLegend.tsx +++ b/packages/grafana-ui/src/components/VizLegend/VizLegend.tsx @@ -28,8 +28,11 @@ export function VizLegend({ }: LegendProps) { const { eventBus, onToggleSeriesVisibility, onToggleLegendSort } = usePanelContext(); - const onMouseEnter = useCallback( - (item: VizLegendItem, event: React.MouseEvent) => { + const onMouseOver = useCallback( + ( + item: VizLegendItem, + event: React.MouseEvent | React.FocusEvent + ) => { eventBus?.publish({ type: DataHoverEvent.type, payload: { @@ -44,7 +47,10 @@ export function VizLegend({ ); const onMouseOut = useCallback( - (item: VizLegendItem, event: React.MouseEvent) => { + ( + item: VizLegendItem, + event: React.MouseEvent | React.FocusEvent + ) => { eventBus?.publish({ type: DataHoverClearEvent.type, payload: { @@ -59,7 +65,7 @@ export function VizLegend({ ); const onLegendLabelClick = useCallback( - (item: VizLegendItem, event: React.MouseEvent) => { + (item: VizLegendItem, event: React.MouseEvent) => { if (onLabelClick) { onLabelClick(item, event); } @@ -86,7 +92,7 @@ export function VizLegend({ sortDesc={sortDesc} onLabelClick={onLegendLabelClick} onToggleSort={onToggleSort || onToggleLegendSort} - onLabelMouseEnter={onMouseEnter} + onLabelMouseOver={onMouseOver} onLabelMouseOut={onMouseOut} itemRenderer={itemRenderer} readonly={readonly} @@ -98,7 +104,7 @@ export function VizLegend({ className={className} items={items} placement={placement} - onLabelMouseEnter={onMouseEnter} + onLabelMouseOver={onMouseOver} onLabelMouseOut={onMouseOut} onLabelClick={onLegendLabelClick} itemRenderer={itemRenderer} diff --git a/packages/grafana-ui/src/components/VizLegend/VizLegendList.tsx b/packages/grafana-ui/src/components/VizLegend/VizLegendList.tsx index c2a14364908..0e6cfce1032 100644 --- a/packages/grafana-ui/src/components/VizLegend/VizLegendList.tsx +++ b/packages/grafana-ui/src/components/VizLegend/VizLegendList.tsx @@ -18,7 +18,7 @@ export interface Props extends VizLegendBaseProps {} export const VizLegendList = ({ items, itemRenderer, - onLabelMouseEnter, + onLabelMouseOver, onLabelMouseOut, onLabelClick, placement, @@ -33,7 +33,7 @@ export const VizLegendList = ({ diff --git a/packages/grafana-ui/src/components/VizLegend/VizLegendListItem.tsx b/packages/grafana-ui/src/components/VizLegend/VizLegendListItem.tsx index 6358ead51a2..4381a3f8f0a 100644 --- a/packages/grafana-ui/src/components/VizLegend/VizLegendListItem.tsx +++ b/packages/grafana-ui/src/components/VizLegend/VizLegendListItem.tsx @@ -13,9 +13,15 @@ import { VizLegendItem } from './types'; export interface Props { item: VizLegendItem; className?: string; - onLabelClick?: (item: VizLegendItem, event: React.MouseEvent) => void; - onLabelMouseEnter?: (item: VizLegendItem, event: React.MouseEvent) => void; - onLabelMouseOut?: (item: VizLegendItem, event: React.MouseEvent) => void; + onLabelClick?: (item: VizLegendItem, event: React.MouseEvent) => void; + onLabelMouseOver?: ( + item: VizLegendItem, + event: React.MouseEvent | React.FocusEvent + ) => void; + onLabelMouseOut?: ( + item: VizLegendItem, + event: React.MouseEvent | React.FocusEvent + ) => void; readonly?: boolean; } @@ -25,24 +31,24 @@ export interface Props { export const VizLegendListItem = ({ item, onLabelClick, - onLabelMouseEnter, + onLabelMouseOver, onLabelMouseOut, className, readonly, }: Props) => { const styles = useStyles2(getStyles); - const onMouseEnter = useCallback( - (event: React.MouseEvent) => { - if (onLabelMouseEnter) { - onLabelMouseEnter(item, event); + const onMouseOver = useCallback( + (event: React.MouseEvent | React.FocusEvent) => { + if (onLabelMouseOver) { + onLabelMouseOver(item, event); } }, - [item, onLabelMouseEnter] + [item, onLabelMouseOver] ); const onMouseOut = useCallback( - (event: React.MouseEvent) => { + (event: React.MouseEvent | React.FocusEvent) => { if (onLabelMouseOut) { onLabelMouseOut(item, event); } @@ -51,7 +57,7 @@ export const VizLegendListItem = ({ ); const onClick = useCallback( - (event: React.MouseEvent) => { + (event: React.MouseEvent) => { if (onLabelClick) { onLabelClick(item, event); } @@ -65,14 +71,18 @@ export const VizLegendListItem = ({ aria-label={selectors.components.VizLegend.seriesName(item.label)} > -
{item.label} -
+ {item.getDisplayValues && } @@ -85,10 +95,10 @@ const getStyles = (theme: GrafanaTheme2) => ({ label: css` label: LegendLabel; white-space: nowrap; - `, - clickable: css` - label: LegendClickabel; - cursor: pointer; + background: none; + border: none; + font-size: inherit; + padding: 0; `, itemDisabled: css` label: LegendLabelDisabled; diff --git a/packages/grafana-ui/src/components/VizLegend/VizLegendTable.tsx b/packages/grafana-ui/src/components/VizLegend/VizLegendTable.tsx index 21e786e6cf5..b384ca4f998 100644 --- a/packages/grafana-ui/src/components/VizLegend/VizLegendTable.tsx +++ b/packages/grafana-ui/src/components/VizLegend/VizLegendTable.tsx @@ -21,7 +21,7 @@ export const VizLegendTable = ({ className, onToggleSort, onLabelClick, - onLabelMouseEnter, + onLabelMouseOver, onLabelMouseOut, readonly, }: VizLegendTableProps): JSX.Element => { @@ -57,7 +57,7 @@ export const VizLegendTable = ({ key={`${item.label}-${index}`} item={item} onLabelClick={onLabelClick} - onLabelMouseEnter={onLabelMouseEnter} + onLabelMouseOver={onLabelMouseOver} onLabelMouseOut={onLabelMouseOut} readonly={readonly} /> diff --git a/packages/grafana-ui/src/components/VizLegend/VizLegendTableItem.tsx b/packages/grafana-ui/src/components/VizLegend/VizLegendTableItem.tsx index cad8a3d9674..fe177bd3447 100644 --- a/packages/grafana-ui/src/components/VizLegend/VizLegendTableItem.tsx +++ b/packages/grafana-ui/src/components/VizLegend/VizLegendTableItem.tsx @@ -13,9 +13,15 @@ export interface Props { key?: React.Key; item: VizLegendItem; className?: string; - onLabelClick?: (item: VizLegendItem, event: React.MouseEvent) => void; - onLabelMouseEnter?: (item: VizLegendItem, event: React.MouseEvent) => void; - onLabelMouseOut?: (item: VizLegendItem, event: React.MouseEvent) => void; + onLabelClick?: (item: VizLegendItem, event: React.MouseEvent) => void; + onLabelMouseOver?: ( + item: VizLegendItem, + event: React.MouseEvent | React.FocusEvent + ) => void; + onLabelMouseOut?: ( + item: VizLegendItem, + event: React.MouseEvent | React.FocusEvent + ) => void; readonly?: boolean; } @@ -25,24 +31,24 @@ export interface Props { export const LegendTableItem: React.FunctionComponent = ({ item, onLabelClick, - onLabelMouseEnter, + onLabelMouseOver, onLabelMouseOut, className, readonly, }) => { const styles = useStyles2(getStyles); - const onMouseEnter = useCallback( - (event: React.MouseEvent) => { - if (onLabelMouseEnter) { - onLabelMouseEnter(item, event); + const onMouseOver = useCallback( + (event: React.MouseEvent | React.FocusEvent) => { + if (onLabelMouseOver) { + onLabelMouseOver(item, event); } }, - [item, onLabelMouseEnter] + [item, onLabelMouseOver] ); const onMouseOut = useCallback( - (event: React.MouseEvent) => { + (event: React.MouseEvent | React.FocusEvent) => { if (onLabelMouseOut) { onLabelMouseOut(item, event); } @@ -51,7 +57,7 @@ export const LegendTableItem: React.FunctionComponent = ({ ); const onClick = useCallback( - (event: React.MouseEvent) => { + (event: React.MouseEvent) => { if (onLabelClick) { onLabelClick(item, event); } @@ -64,14 +70,18 @@ export const LegendTableItem: React.FunctionComponent = ({ -
{item.label} {item.yAxis === 2 && (right y-axis)} -
+
{item.getDisplayValues && @@ -108,15 +118,15 @@ const getStyles = (theme: GrafanaTheme2) => { label: css` label: LegendLabel; white-space: nowrap; + background: none; + border: none; + font-size: inherit; + padding: 0; `, labelDisabled: css` label: LegendLabelDisabled; color: ${theme.colors.text.disabled}; `, - clickable: css` - label: LegendClickable; - cursor: pointer; - `, itemWrapper: css` display: flex; white-space: nowrap; diff --git a/packages/grafana-ui/src/components/VizLegend/types.ts b/packages/grafana-ui/src/components/VizLegend/types.ts index 23b1596a388..d7a7c0c3b7f 100644 --- a/packages/grafana-ui/src/components/VizLegend/types.ts +++ b/packages/grafana-ui/src/components/VizLegend/types.ts @@ -13,10 +13,16 @@ export interface VizLegendBaseProps { className?: string; items: Array>; seriesVisibilityChangeBehavior?: SeriesVisibilityChangeBehavior; - onLabelClick?: (item: VizLegendItem, event: React.MouseEvent) => void; + onLabelClick?: (item: VizLegendItem, event: React.MouseEvent) => void; itemRenderer?: (item: VizLegendItem, index: number) => JSX.Element; - onLabelMouseEnter?: (item: VizLegendItem, event: React.MouseEvent) => void; - onLabelMouseOut?: (item: VizLegendItem, event: React.MouseEvent) => void; + onLabelMouseOver?: ( + item: VizLegendItem, + event: React.MouseEvent | React.FocusEvent + ) => void; + onLabelMouseOut?: ( + item: VizLegendItem, + event: React.MouseEvent | React.FocusEvent + ) => void; readonly?: boolean; } diff --git a/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanBar.tsx b/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanBar.tsx index 22897db0b25..da6869de883 100644 --- a/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanBar.tsx +++ b/packages/jaeger-ui-components/src/TraceTimelineViewer/SpanBar.tsx @@ -147,8 +147,10 @@ function SpanBar({ return (
setIsMouseOver(false)} + onFocus={() => setIsMouseOver(true)} onMouseOver={() => setIsMouseOver(true)} - onMouseLeave={() => setIsMouseOver(false)} + onMouseOut={() => setIsMouseOver(false)} >