Skip to content

Commit

Permalink
Fix invalid aria-describedby values set by EuiToolTip (#1533)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michail Yasonik committed Jul 23, 2019
1 parent a276b77 commit 6b3b498
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Added `partial` glyph to `EuiIcon` ([#2152](https://github.com/elastic/eui/pull/2152))
- Fixed invalid `aria-desribedby` values set by `EuiToolTip` ([#2156](https://github.com/elastic/eui/pull/2156))

## [`13.0.0`](https://github.com/elastic/eui/tree/v13.0.0)

Expand Down
4 changes: 0 additions & 4 deletions src/components/tool_tip/__snapshots__/icon_tip.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ exports[`EuiIconTip is rendered 1`] = `
class="euiToolTipAnchor"
>
<svg
aria-describedby="id"
aria-label="aria-label"
class="euiIcon euiIcon--medium euiIcon-isLoading"
focusable="true"
Expand All @@ -23,7 +22,6 @@ exports[`EuiIconTip props color is rendered as the icon color 1`] = `
class="euiToolTipAnchor"
>
<svg
aria-describedby="id"
aria-label="Info"
class="euiIcon euiIcon--medium euiIcon--warning euiIcon-isLoading"
focusable="true"
Expand All @@ -41,7 +39,6 @@ exports[`EuiIconTip props size is rendered as the icon size 1`] = `
class="euiToolTipAnchor"
>
<svg
aria-describedby="id"
aria-label="Info"
class="euiIcon euiIcon--xLarge euiIcon-isLoading"
focusable="true"
Expand All @@ -59,7 +56,6 @@ exports[`EuiIconTip props type is rendered as the icon 1`] = `
class="euiToolTipAnchor"
>
<svg
aria-describedby="id"
aria-label="Info"
class="euiIcon euiIcon--medium euiIcon-isLoading"
focusable="true"
Expand Down
11 changes: 11 additions & 0 deletions src/components/tool_tip/__snapshots__/tool_tip.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiToolTip is rendered 1`] = `
<span
class="euiToolTipAnchor"
>
<button>
Trigger
</button>
</span>
`;

exports[`EuiToolTip shows tooltip on focus 1`] = `
<span
class="euiToolTipAnchor"
>
<button
aria-describedby="id"
data-test-subj="trigger"
>
Trigger
</button>
Expand Down
21 changes: 18 additions & 3 deletions src/components/tool_tip/tool_tip.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React from 'react';
import { render } from 'enzyme';
import { requiredProps } from '../../test';

import { render, mount } from 'enzyme';
import {
requiredProps,
findTestSubject,
takeMountedSnapshot,
} from '../../test';
import { EuiToolTip } from './tool_tip';

describe('EuiToolTip', () => {
Expand All @@ -14,4 +17,16 @@ describe('EuiToolTip', () => {

expect(component).toMatchSnapshot();
});

test('shows tooltip on focus', () => {
const component = mount(
<EuiToolTip title="title" id="id" content="content" {...requiredProps}>
<button data-test-subj="trigger">Trigger</button>
</EuiToolTip>
);

const trigger = findTestSubject(component, 'trigger');
trigger.simulate('focus');
expect(takeMountedSnapshot(component)).toMatchSnapshot();
});
});
2 changes: 1 addition & 1 deletion src/components/tool_tip/tool_tip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export class EuiToolTip extends Component<Props, State> {
{cloneElement(children, {
onFocus: this.showToolTip,
onBlur: this.hideToolTip,
'aria-describedby': this.state.id,
...(visible && { 'aria-describedby': this.state.id }),
})}
</span>
);
Expand Down

0 comments on commit 6b3b498

Please sign in to comment.