From 078d716be9aee709c879b3d4456f4861a839acee Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Fri, 23 Jul 2021 10:12:16 +0200 Subject: [PATCH] IconButton: Put tooltip text as aria-label (#36760) (#37137) * Make tooltip prop aria-label * Add ariaLabel prop (cherry picked from commit 8af83b8b78c7c887928f13501d2046feeb9dd1fd) Co-authored-by: Tobias Skarhed <1438972+tskarhed@users.noreply.github.com> --- .../src/components/IconButton/IconButton.tsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/grafana-ui/src/components/IconButton/IconButton.tsx b/packages/grafana-ui/src/components/IconButton/IconButton.tsx index 6b745461282..43c000d9d94 100644 --- a/packages/grafana-ui/src/components/IconButton/IconButton.tsx +++ b/packages/grafana-ui/src/components/IconButton/IconButton.tsx @@ -26,17 +26,32 @@ export interface Props extends React.ButtonHTMLAttributes { tooltipPlacement?: TooltipPlacement; /** Variant to change the color of the Icon */ variant?: IconButtonVariant; + /** Text avilable ony for screenscreen readers. Will use tooltip text as fallback. */ + ariaLabel?: string; } type SurfaceType = 'dashboard' | 'panel' | 'header'; export const IconButton = React.forwardRef( - ({ name, size = 'md', iconType, tooltip, tooltipPlacement, className, variant = 'secondary', ...restProps }, ref) => { + ( + { + name, + size = 'md', + iconType, + tooltip, + tooltipPlacement, + ariaLabel, + className, + variant = 'secondary', + ...restProps + }, + ref + ) => { const theme = useTheme2(); const styles = getStyles(theme, size, variant); const button = ( - );