From 6037562c9a6422628e8b927647cc9d7eb1d388de Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Wed, 7 Dec 2022 13:53:24 +0100 Subject: [PATCH] [v9.3.x] Accessibility: Improved keyboard accessibility in BarGauge (#59653) Accessibility: Improved keyboard accessibility in BarGauge (#59382) * Accessibility: Improved keyboard accessibility in BarGauge * use appropriate elements when rendering bargauge * added space for focus-visible outline border * Revert "added space for focus-visible outline border" This reverts commit 9b83fa3a0b0a96c3e319e182a3deafdb973aad12. (cherry picked from commit d9f697b41eabac549e648c1487d13f1eea4a84cc) Co-authored-by: Leo <108552997+lpskdl@users.noreply.github.com> --- .../src/components/BarGauge/BarGauge.tsx | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/grafana-ui/src/components/BarGauge/BarGauge.tsx b/packages/grafana-ui/src/components/BarGauge/BarGauge.tsx index fd5bd1ad8d9..ac80738dd0e 100644 --- a/packages/grafana-ui/src/components/BarGauge/BarGauge.tsx +++ b/packages/grafana-ui/src/components/BarGauge/BarGauge.tsx @@ -1,4 +1,5 @@ // Library +import { cx } from '@emotion/css'; import React, { CSSProperties, PureComponent, ReactNode } from 'react'; import tinycolor from 'tinycolor2'; @@ -23,6 +24,7 @@ import { VizTextDisplayOptions } from '@grafana/schema'; import { Themeable2 } from '../../types'; import { calculateFontSize, measureText } from '../../utils/measureText'; +import { clearButtonStyles } from '../Button'; import { FormattedValueDisplay } from '../FormattedValueDisplay/FormattedValueDisplay'; const MIN_VALUE_HEIGHT = 18; @@ -77,21 +79,27 @@ export class BarGauge extends PureComponent { }; render() { - const { onClick, className } = this.props; + const { onClick, className, theme } = this.props; const { title } = this.props.value; const styles = getTitleStyles(this.props); - if (!title) { + if (onClick) { return ( -
+
+ ); } return ( -
-
{title}
+
+ {title &&
{title}
} {this.renderBarAndValue()}
);