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 EuiToolTip mouseout logic. #564

Merged
merged 2 commits into from
Mar 22, 2018
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
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

**Bug fixes**

- Fixed `EuiToolTip` bug which caused the tooltip to hide when moving the mouse around inside of the trigger element ([#557](https://github.com/elastic/eui/pull/557))
- Fixed `EuiToolTip` bug which caused the tooltip to hide when moving the mouse around inside of the trigger element ([#557](https://github.com/elastic/eui/pull/557), [#564](https://github.com/elastic/eui/pull/564))
- Added a `buttonColor` prop to `EuiConfirmModal` ([#546](https://github.com/elastic/eui/pull/546))
- Added baseline as option to `EuiFlexGroup`'s `alignItems` prop ([#546](https://github.com/elastic/eui/pull/546))
- Added 'baseline' as option to `EuiFlexGroup`'s `alignItems` prop ([#546](https://github.com/elastic/eui/pull/546))
- Fixed a bug where `EuiButtonEmpty` would offer a white background on hover when it was disabled, even when there was no such background transition on hover when the buttons are not disabled ([#561](https://github.com/elastic/eui/pull/561))

# [`0.0.33`](https://github.com/elastic/eui/tree/v0.0.33)
Expand Down
6 changes: 3 additions & 3 deletions src-docs/src/views/filter_group/filter_group_example.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { Fragment } from 'react';

import { renderToHtml } from '../../services';

Expand All @@ -22,7 +22,7 @@ const filterGroupHtml = renderToHtml(FilterGroup);
export const FilterGroupExample = {
title: 'Filter Group',
intro: (
<div>
<Fragment>
<EuiCallOut
title="Demo of visual pattern only"
color="warning"
Expand All @@ -37,7 +37,7 @@ export const FilterGroupExample = {
</EuiCallOut>

<EuiSpacer size="l" />
</div>
</Fragment>
),
sections: [{
source: [{
Expand Down
6 changes: 3 additions & 3 deletions src-docs/src/views/flex/flex_example.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { Fragment } from 'react';

import { renderToHtml } from '../../services';

Expand Down Expand Up @@ -72,7 +72,7 @@ const flexGroupResonsiveHtml = renderToHtml(FlexGroupResponsive);
export const FlexExample = {
title: 'Flex',
intro: (
<div>
<Fragment>
<EuiCallOut
title="Coloring and padding exist for examples only"
color="warning"
Expand All @@ -85,7 +85,7 @@ export const FlexExample = {
</EuiCallOut>

<EuiSpacer size="l" />
</div>
</Fragment>
),
sections: [{
title: 'FlexGroup is for a single row layout',
Expand Down
6 changes: 3 additions & 3 deletions src-docs/src/views/spacer/spacer_example.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { Fragment } from 'react';

import { renderToHtml } from '../../services';

Expand All @@ -20,7 +20,7 @@ const spacerHtml = renderToHtml(Spacer);
export const SpacerExample = {
title: 'Spacer',
intro: (
<div>
<Fragment>
<EuiCallOut
title="Try not to stuff these in loops"
color="warning"
Expand All @@ -37,7 +37,7 @@ export const SpacerExample = {
</EuiCallOut>

<EuiSpacer size="l" />
</div>
</Fragment>
),
sections: [{
source: [{
Expand Down
15 changes: 12 additions & 3 deletions src-docs/src/views/tool_tip/tool_tip.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export default () => (
<EuiText>
<p>
This tooltip appears on the{' '}
<EuiToolTip position="top" content="Here is some tooltip text">
<EuiToolTip
position="top"
content="Here is some tooltip text"
>
<EuiLink href="#">top</EuiLink>
</EuiToolTip>
</p>
Expand All @@ -34,14 +37,20 @@ export default () => (

<p>
This tooltip appears on the{' '}
<EuiToolTip position="right" content="Here is some tooltip text">
<EuiToolTip
position="right"
content="Here is some tooltip text"
>
<EuiLink href="#">right</EuiLink>
</EuiToolTip>
</p>

<p>
This tooltip appears on the bottom of this icon:{' '}
<EuiToolTip position="bottom" content="Here is some tooltip text">
<EuiToolTip
position="bottom"
content="Here is some tooltip text"
>
<EuiIcon tabIndex="0" type="alert" title="Icon with tooltip" />
</EuiToolTip>
</p>
Expand Down
16 changes: 16 additions & 0 deletions src-docs/src/views/tool_tip/tool_tip_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import {
} from '../../components';

import {
EuiCallOut,
EuiCode,
EuiToolTip,
EuiIconTip,
EuiSpacer,
} from '../../../../src/components';

import ToolTip from './tool_tip';
Expand All @@ -22,6 +24,20 @@ const infoTipHtml = renderToHtml(IconTip);

export const ToolTipExample = {
title: 'ToolTip',
intro: (
<Fragment>
<EuiCallOut
title="EuiToolTip only applies to inline elements"
>
<p>
EuiToolTip wraps its children in a span element, so if you pass in a block-level child
(e.g. a div) the resulting DOM will be in violation of the HTML5 spec.
</p>
</EuiCallOut>

<EuiSpacer size="l" />
</Fragment>
),
sections: [{
source: [{
type: GuideSectionTypes.JS,
Expand Down
8 changes: 6 additions & 2 deletions src/components/tool_tip/__snapshots__/icon_tip.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiIconTip is rendered 1`] = `
<span>
<span
class="euiToolTipAnchor"
>
<svg
aria-describedby="id"
aria-label="aria-label"
Expand All @@ -23,7 +25,9 @@ exports[`EuiIconTip is rendered 1`] = `
`;

exports[`EuiIconTip props type is rendered as the icon 1`] = `
<span>
<span
class="euiToolTipAnchor"
>
<svg
aria-describedby="id"
aria-label="Info"
Expand Down
4 changes: 3 additions & 1 deletion src/components/tool_tip/__snapshots__/tool_tip.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiToolTip is rendered 1`] = `
<span>
<span
class="euiToolTipAnchor"
>
<button
aria-describedby="id"
>
Expand Down
3 changes: 3 additions & 0 deletions src/components/tool_tip/_tool_tip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
}
}

.euiToolTipAnchor {
display: inline-block;
}

// Keyframes to animate in the tooltip.
@keyframes euiToolTipTop {
Expand Down
22 changes: 12 additions & 10 deletions src/components/tool_tip/tool_tip.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,12 @@ export class EuiToolTip extends Component {
};

onMouseOut = (e) => {
if (e.target !== e.currentTarget) {
// We've moused out of a child element, but we haven't yet left the root trigger element.
return;
}

if (!this.state.hasFocus) {
this.hideToolTip();
// Prevent mousing over children from hiding the tooltip by testing for whether the mouse has
// left the anchor for a non-child.
if (this.anchor === e.relatedTarget || !this.anchor.contains(e.relatedTarget)) {
if (!this.state.hasFocus) {
this.hideToolTip();
}
}
};

Expand Down Expand Up @@ -119,8 +118,11 @@ export class EuiToolTip extends Component {
);
}

const trigger = (
<span ref={anchor => this.anchor = anchor}>
const anchor = (
<span
ref={anchor => this.anchor = anchor}
className="euiToolTipAnchor"
>
{cloneElement(children, {
onFocus: this.showToolTip,
onBlur: this.hideToolTip,
Expand All @@ -133,7 +135,7 @@ export class EuiToolTip extends Component {

return (
<Fragment>
{trigger}
{anchor}
{tooltip}
</Fragment>
);
Expand Down