Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid aria-describedby values set by EuiToolTip (#1533) #2156

Merged
merged 1 commit into from
Jul 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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