Skip to content

Commit a2816f7

Browse files
committed
[EuiIconTip] Fix non-i18n'd aria-label
1 parent 65f24f8 commit a2816f7

2 files changed

Lines changed: 22 additions & 13 deletions

File tree

changelogs/upcoming/7606.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
**Bug fixes**
2+
3+
- Fixed `EuiIconTip`'s default `aria-label` text to be i18n tokenizable
4+
15
**Accessibility**
26

37
- `EuiIcons` no longer apply `aria-hidden` to empty icons, as long as a valid title or label is provided to the icon. In particular, this is intended to improve the accessibility of loading `EuiIconTip`s.

src/components/tool_tip/icon_tip.tsx

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import React, { FunctionComponent } from 'react';
1010

1111
import { PropsOf } from '../common';
12+
import { useEuiI18n } from '../i18n';
1213
import { EuiIcon, IconSize, IconType } from '../icon';
1314
import { EuiToolTip, EuiToolTipProps } from './tool_tip';
1415

@@ -53,22 +54,26 @@ type Props = Omit<EuiToolTipProps, 'children' | 'delay' | 'position'> &
5354

5455
export const EuiIconTip: FunctionComponent<Props> = ({
5556
type = 'questionInCircle',
56-
'aria-label': ariaLabel = 'Info',
57+
'aria-label': ariaLabel,
5758
color,
5859
size,
5960
iconProps,
6061
position = 'top',
6162
delay = 'regular',
6263
...rest
63-
}) => (
64-
<EuiToolTip position={position} delay={delay} {...rest}>
65-
<EuiIcon
66-
tabIndex={0}
67-
type={type}
68-
color={color}
69-
size={size}
70-
aria-label={ariaLabel}
71-
{...iconProps}
72-
/>
73-
</EuiToolTip>
74-
);
64+
}) => {
65+
const defaultAriaLabel = useEuiI18n('euiIconTip.defaultAriaLabel', 'Info');
66+
67+
return (
68+
<EuiToolTip position={position} delay={delay} {...rest}>
69+
<EuiIcon
70+
tabIndex={0}
71+
type={type}
72+
color={color}
73+
size={size}
74+
aria-label={ariaLabel || defaultAriaLabel}
75+
{...iconProps}
76+
/>
77+
</EuiToolTip>
78+
);
79+
};

0 commit comments

Comments
 (0)