Skip to content

Commit 16e1d7c

Browse files
fix(charts): use toggleLegendButtonTitle as EuiToolTip content on LegendToggle
1 parent e2bf797 commit 16e1d7c

1 file changed

Lines changed: 23 additions & 17 deletions

File tree

src/platform/plugins/shared/charts/public/static/components/legend_toggle.tsx

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import React, { memo, useMemo } from 'react';
1111
import { i18n } from '@kbn/i18n';
12-
import { EuiButtonIcon, useEuiTheme } from '@elastic/eui';
12+
import { EuiButtonIcon, EuiToolTip, useEuiTheme } from '@elastic/eui';
1313
import type { Position } from '@elastic/charts';
1414
import { css } from '@emotion/react';
1515

@@ -51,24 +51,30 @@ const LegendToggleComponent = ({ onClick, showLegend, legendPosition }: LegendTo
5151
);
5252

5353
return (
54-
// eslint-disable-next-line @elastic/eui/tooltip-button-icon-wrap -- absolute-positioned chart overlay; EuiToolTip wrapper alters snapshot rendering
55-
<EuiButtonIcon
56-
type="button"
57-
iconType="listBullet"
58-
color="text"
59-
onClick={onClick}
60-
css={[
61-
baseStyles,
62-
showLegend ? isOpenStyle : null,
63-
['left', 'bottom'].includes(legendPosition) ? positionStyle : null,
64-
]}
65-
aria-label={i18n.translate('charts.legend.toggleLegendButtonAriaLabel', {
54+
<EuiToolTip
55+
content={i18n.translate('charts.legend.toggleLegendButtonTitle', {
6656
defaultMessage: 'Toggle legend',
6757
})}
68-
aria-expanded={showLegend}
69-
isSelected={showLegend}
70-
data-test-subj="vislibToggleLegend"
71-
/>
58+
disableScreenReaderOutput
59+
>
60+
<EuiButtonIcon
61+
type="button"
62+
iconType="listBullet"
63+
color="text"
64+
onClick={onClick}
65+
css={[
66+
baseStyles,
67+
showLegend ? isOpenStyle : null,
68+
['left', 'bottom'].includes(legendPosition) ? positionStyle : null,
69+
]}
70+
aria-label={i18n.translate('charts.legend.toggleLegendButtonAriaLabel', {
71+
defaultMessage: 'Toggle legend',
72+
})}
73+
aria-expanded={showLegend}
74+
isSelected={showLegend}
75+
data-test-subj="vislibToggleLegend"
76+
/>
77+
</EuiToolTip>
7278
);
7379
};
7480

0 commit comments

Comments
 (0)