Skip to content

Commit 1ba7953

Browse files
author
Dominik Sumer
committed
renamed ariaId to simple id prop
1 parent 04b560a commit 1ba7953

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Online examples: [http://react-component.github.io/tooltip/examples/](http://rea
177177
<td>whether destroy tooltip when tooltip is hidden</td>
178178
</tr>
179179
<tr>
180-
<td>ariaId</td>
180+
<td>id</td>
181181
<td>String</td>
182182
<td></td>
183183
<td>Id which gets attached to the tooltip content. Can be used with aria-describedby to achieve Screenreader-Support.</td>
@@ -189,6 +189,20 @@ Online examples: [http://react-component.github.io/tooltip/examples/](http://rea
189189

190190
`Tooltip` requires child node accepts `onMouseEnter`, `onMouseLeave`, `onFocus`, `onClick` event.
191191

192+
## Accessibility
193+
194+
For accesibility purpose you can use the `id` prop to link your tooltip with another element. For example attaching it with an input:
195+
```jsx
196+
<Tooltip
197+
...
198+
id={this.props.name}
199+
<input className={className}
200+
type="text"
201+
...
202+
aria-describedby={this.props.name}/>
203+
</Tooltip>
204+
```
205+
If you do it like this, a screenreader would read the content of your tooltip if you focus the input element.
192206

193207
## Development
194208

src/Tooltip.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Tooltip extends Component {
2727
destroyTooltipOnHide: PropTypes.bool,
2828
align: PropTypes.object,
2929
arrowContent: PropTypes.any,
30-
ariaId: PropTypes.string,
30+
id: PropTypes.string,
3131
};
3232

3333
static defaultProps = {
@@ -42,12 +42,12 @@ class Tooltip extends Component {
4242
};
4343

4444
getPopupElement = () => {
45-
const { arrowContent, overlay, prefixCls, ariaId } = this.props;
45+
const { arrowContent, overlay, prefixCls, id } = this.props;
4646
return ([
4747
<div className={`${prefixCls}-arrow`} key="arrow">
4848
{arrowContent}
4949
</div>,
50-
<div className={`${prefixCls}-inner`} key="content" id={ariaId}>
50+
<div className={`${prefixCls}-inner`} key="content" id={id}>
5151
{typeof overlay === 'function' ? overlay() : overlay}
5252
</div>,
5353
]);

0 commit comments

Comments
 (0)