From ecaaa0acda0e84e17163ac8290ef15e30112d019 Mon Sep 17 00:00:00 2001
From: Caroline Horn <549577+cchaos@users.noreply.github.com>
Date: Tue, 24 Aug 2021 15:48:49 -0400
Subject: [PATCH] [EuiTooltip] Revert "Remove tooltip focus on mousemove
(#3335)" and force visibility while element is focused (#5066)
* Revert "Remove tooltip focus on mousemove (#3335)"
* Applying `onFocus` and `onBlur` methods to child clone
* Put default value for `display` in `defaultProps` so it populates in the props table
* [EuiIconTip] Removing `children` from TS
---
CHANGELOG.md | 7 +-
src-docs/src/views/tool_tip/playground.js | 46 +++++-
src-docs/src/views/tool_tip/tool_tip.js | 47 +-----
.../src/views/tool_tip/tool_tip_components.js | 47 ++++++
.../src/views/tool_tip/tool_tip_example.js | 145 ++++++++++--------
.../default_item_action.test.tsx.snap | 4 +
.../__snapshots__/code_block.test.tsx.snap | 2 +-
.../copy/__snapshots__/copy.test.tsx.snap | 1 +
.../super_update_button.test.tsx.snap | 5 +
src/components/tool_tip/icon_tip.tsx | 4 +
src/components/tool_tip/tool_tip.tsx | 37 +++--
11 files changed, 217 insertions(+), 128 deletions(-)
create mode 100644 src-docs/src/views/tool_tip/tool_tip_components.js
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 74ef3bb098b..255ec649d58 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,11 @@
## [`master`](https://github.com/elastic/eui/tree/master)
-No public interface changes since `37.3.1`.
+- Updated `EuiToolTip` to remain showing tooltip while child element is in focus ([#5066](https://github.com/elastic/eui/pull/5066))
+- Removed `children` from TypeScript definition in `EuiIconTip` ([#5066](https://github.com/elastic/eui/pull/5066))
+
+**Bug fixes**
+
+- Fixed location of default value of `EuiToolTip`'s `display` prop ([#5066](https://github.com/elastic/eui/pull/5066))
## [`37.3.1`](https://github.com/elastic/eui/tree/v37.3.1)
diff --git a/src-docs/src/views/tool_tip/playground.js b/src-docs/src/views/tool_tip/playground.js
index 4d8d12f3386..17a6fba38d9 100644
--- a/src-docs/src/views/tool_tip/playground.js
+++ b/src-docs/src/views/tool_tip/playground.js
@@ -1,12 +1,13 @@
import { PropTypes } from 'react-view';
-import { EuiToolTip } from '../../../../src/components/';
+import { EuiToolTip, EuiIconTip } from '../../../../src/components';
import {
propUtilityForPlayground,
dummyFunction,
simulateFunction,
+ iconValidator,
} from '../../services/playground';
-export default () => {
+export const toolTipConfig = () => {
const docgenInfo = Array.isArray(EuiToolTip.__docgenInfo)
? EuiToolTip.__docgenInfo[0]
: EuiToolTip.__docgenInfo;
@@ -51,3 +52,44 @@ export default () => {
},
};
};
+
+export const iconTipConfig = () => {
+ const docgenInfo = Array.isArray(EuiIconTip.__docgenInfo)
+ ? EuiIconTip.__docgenInfo[0]
+ : EuiIconTip.__docgenInfo;
+ const propsToUse = propUtilityForPlayground(docgenInfo.props);
+
+ propsToUse.type = iconValidator(propsToUse.type);
+
+ propsToUse.title = {
+ ...propsToUse.title,
+ type: PropTypes.String,
+ value: 'Title',
+ };
+
+ propsToUse.content = {
+ ...propsToUse.content,
+ type: PropTypes.String,
+ value: 'Content',
+ };
+
+ propsToUse.onMouseOut = simulateFunction(propsToUse.onMouseOut);
+
+ return {
+ config: {
+ componentName: 'EuiIconTip',
+ props: propsToUse,
+ scope: {
+ EuiIconTip,
+ },
+ imports: {
+ '@elastic/eui': {
+ named: ['EuiIconTip'],
+ },
+ },
+ customProps: {
+ onMouseOut: dummyFunction,
+ },
+ },
+ };
+};
diff --git a/src-docs/src/views/tool_tip/tool_tip.js b/src-docs/src/views/tool_tip/tool_tip.js
index cc8e4017890..87d8655027e 100644
--- a/src-docs/src/views/tool_tip/tool_tip.js
+++ b/src-docs/src/views/tool_tip/tool_tip.js
@@ -5,9 +5,7 @@ import {
EuiToolTip,
EuiLink,
EuiText,
- EuiFieldText,
- EuiSpacer,
- EuiButton,
+ EuiCode,
} from '../../../../src/components';
export default () => (
@@ -18,6 +16,7 @@ export default () => (
@@ -37,14 +36,16 @@ export default () => (
- This tooltip has a long delay because it might be in a repeatable
- component{' '}
+ This tooltip has a long
@@ -54,41 +55,5 @@ export default () => (
- -
-
- 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. + Generally, tooltips should provide short, non-essential + , contextual information, usually naming or describing with more detail. + If you need interactive content or anything other than text, we + recommend using{' '} + + EuiPopover + {' '} + instead.
- + +
Wrap EuiToolTip around any item that you need a
- tooltip for. The
- Internally, EuiToolTip applies{' '}
-
+ EuiToolTip wraps its children in a{' '}
+
+ It also applies
@@ -157,10 +164,16 @@ export const ToolTipExample = {