Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7204c9d
refactor(eui): migrate EuiToolTip to functional component
weronikaolejniczak Apr 7, 2026
7e4fec1
refactor(eui): memoize EuiToolTip styles
weronikaolejniczak Apr 7, 2026
45cc756
refactor(eui): update EuiToolTip usages
weronikaolejniczak Apr 7, 2026
451f7a5
chore(eui): update VRT reference images
weronikaolejniczak Apr 7, 2026
221f34e
chore(eui): update EuiToolTip test suite
weronikaolejniczak Apr 7, 2026
fcc3c7e
chore(eui): update EuiIconTip test suite
weronikaolejniczak Apr 7, 2026
d7c08d6
chore(eui): add filter select item tooltip test
weronikaolejniczak Apr 8, 2026
722bc07
REMOVE BEFORE MERGE - temp stories
weronikaolejniczak Apr 8, 2026
b806650
refactor(eui): update nits after review
weronikaolejniczak Apr 8, 2026
d226eb5
fix(eui): fix tooltip reposition on resize window
weronikaolejniczak Apr 8, 2026
a38e23d
fix(eui): position tooltip on mount fixing StrictMode
weronikaolejniczak Apr 8, 2026
402d1a1
chore(eui): just some formatting weirdness
weronikaolejniczak Apr 8, 2026
88161ad
refactor(eui): narrow types in EuiToolTip
weronikaolejniczak Apr 9, 2026
a89ee57
chore(eui): change test to it in filter select item test
weronikaolejniczak Apr 9, 2026
d9cec6d
fix(eui): use ref on htmlIdGenerator return value
weronikaolejniczak Apr 9, 2026
cede9a3
chore(eui): update assertions in EuiIconTip tests
weronikaolejniczak Apr 9, 2026
03ca9cd
chore(eui): rephrase stale comment
weronikaolejniczak Apr 9, 2026
8a2d8e1
chore(eui): update comment
weronikaolejniczak Apr 9, 2026
c508ee3
Merge remote-tracking branch 'upstream/main' into chore/refactor-tooltip
tkajtoch Apr 20, 2026
d827e24
chore(eui): fix the typo in comment
weronikaolejniczak Apr 27, 2026
eeac8f7
chore(eui): add a test for StrictMode autoFocus
weronikaolejniczak Apr 27, 2026
bb46282
fix(eui): fix tooltip not showing on autoFocus in StrictMode
weronikaolejniczak Apr 27, 2026
38163a8
fix(eui): wrap hideToolTip with isMounted condition
weronikaolejniczak Apr 27, 2026
5ba550b
chore: revert temp stories
weronikaolejniczak Apr 27, 2026
53bbe85
Merge branch 'main' into chore/refactor-tooltip
weronikaolejniczak Apr 28, 2026
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Copy link
Copy Markdown
Contributor Author

@weronikaolejniczak weronikaolejniczak Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an expected change. Previously, position leaked to the DOM element but it's not a valid HTML attribute. Same as offset.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ exports[`EuiCollapsedNavButton renders a tooltip around the icon button 1`] = `
class="euiToolTipPopover euiToolTip emotion-euiToolTip-left-euiCollapsedNavItemTooltip-left"
data-position="left"
id="generated-id"
position="left"
role="tooltip"
style="top: -10px; left: -16px;"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ exports[`EuiContextMenuItem tooltip behavior 1`] = `
class="euiToolTipPopover euiToolTip emotion-euiToolTip-top"
data-position="top"
id="generated-id"
position="top"
role="tooltip"
style="top: -16px; left: -10px;"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
*/

import React from 'react';
import { render } from '../../test/rtl';
import {
render,
waitForEuiToolTipVisible,
waitForEuiToolTipHidden,
} from '../../test/rtl';
import { requiredProps } from '../../test';
import { shouldRenderCustomStyles } from '../../test/internal';

Expand All @@ -21,4 +25,57 @@ describe('EuiFilterSelectItem', () => {

expect(container.firstChild).toMatchSnapshot();
});

describe('tooltip behavior', () => {
const tooltipProps = {
toolTipContent: 'Filter item tooltip',
toolTipProps: { 'data-test-subj': 'filterItemToolTip' },
};

// `toggleToolTip` is called in `componentDidUpdate`; on initial mount `tooltipRef.current`
// is null because `EuiToolTip` hasn't committed its ref yet, so a re-render is required
// to trigger `showToolTip`/`hideToolTip`.
it('shows tooltip when `isFocused` becomes true', async () => {
const { rerender, getByTestSubject } = render(
<EuiFilterSelectItem {...tooltipProps} isFocused={false}>
<span>Item</span>
</EuiFilterSelectItem>
);

rerender(
<EuiFilterSelectItem {...tooltipProps} isFocused={true}>
<span>Item</span>
</EuiFilterSelectItem>
);

await waitForEuiToolTipVisible();
expect(getByTestSubject('filterItemToolTip')).toBeInTheDocument();
});

it('hides tooltip when `isFocused` becomes false', async () => {
const { rerender, queryByRole } = render(
<EuiFilterSelectItem {...tooltipProps} isFocused={false}>
<span>Item</span>
</EuiFilterSelectItem>
);

rerender(
<EuiFilterSelectItem {...tooltipProps} isFocused={true}>
<span>Item</span>
</EuiFilterSelectItem>
);

await waitForEuiToolTipVisible();
expect(queryByRole('tooltip')).toBeInTheDocument();

rerender(
<EuiFilterSelectItem {...tooltipProps} isFocused={false}>
<span>Item</span>
</EuiFilterSelectItem>
);

await waitForEuiToolTipHidden();
expect(queryByRole('tooltip')).not.toBeInTheDocument();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { CommonProps } from '../common';

import { EuiFlexGroup, EuiFlexItem } from '../flex';
import { EuiToolTip } from '../tool_tip';
import type { EuiToolTipRef } from '../tool_tip';
import { EuiIcon } from '../icon';
import { EuiComboBoxOptionOption } from '../combo_box';

Expand Down Expand Up @@ -62,7 +63,7 @@ export class EuiFilterSelectItemClass extends Component<
};

buttonRef: HTMLButtonElement | null = null;
tooltipRef = createRef<EuiToolTip>();
tooltipRef = createRef<EuiToolTipRef>();

state = {
hasFocus: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,6 @@ exports[`EuiSelectableListItem props tooltip behavior on mouseover 1`] = `
data-position="top"
data-test-subj="listItemToolTip"
id="generated-id"
position="top"
role="tooltip"
style="top: -16px; left: -10px;"
>
Expand Down Expand Up @@ -628,7 +627,6 @@ exports[`EuiSelectableListItem props tooltip behavior when isFocused 1`] = `
data-position="top"
data-test-subj="listItemToolTip"
id="generated-id"
position="top"
role="tooltip"
style="top: -16px; left: -10px;"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { EuiIcon, IconColor, IconType } from '../../icon';
import { EuiScreenReaderOnly } from '../../accessibility';
import { EuiBadge, EuiBadgeProps } from '../../badge';
import { EuiToolTip } from '../../tool_tip';
import type { EuiToolTipRef } from '../../tool_tip';

import type {
EuiSelectableOption,
Expand Down Expand Up @@ -358,7 +359,7 @@ export const EuiSelectableListItem: FunctionComponent<
}, [role, checked]);

const hasToolTip = !!toolTipContent && !disabled;
const [tooltipRef, setTooltipRef] = useState<EuiToolTip | null>(null); // Needs to be state and not a ref to trigger useEffect
const [tooltipRef, setTooltipRef] = useState<EuiToolTipRef | null>(null); // Needs to be state and not a ref to trigger useEffect
const [ariaDescribedBy, setAriaDescribedBy] = useState(_ariaDescribedBy);

// Manually trigger the tooltip on keyboard focus
Expand All @@ -375,7 +376,7 @@ export const EuiSelectableListItem: FunctionComponent<
// Manually set the `aria-describedby` id on the <li> wrapper
useEffect(() => {
if (tooltipRef) {
const tooltipId = tooltipRef.state.id;
const tooltipId = tooltipRef.id;
setAriaDescribedBy(classNames(tooltipId, _ariaDescribedBy));
}
}, [tooltipRef, _ariaDescribedBy]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,3 @@ exports[`EuiIconTip is rendered 1`] = `
</span>
</span>
`;

exports[`EuiIconTip props color is rendered as the icon color 1`] = `
<span
class="euiToolTipAnchor emotion-euiToolTipAnchor-inlineBlock"
id="id-wrapper"
>
<span
color="warning"
data-euiicon-type="question"
tabindex="0"
>
Info
</span>
</span>
`;

exports[`EuiIconTip props size is rendered as the icon size 1`] = `
<span
class="euiToolTipAnchor emotion-euiToolTipAnchor-inlineBlock"
id="id-wrapper"
>
<span
data-euiicon-type="question"
tabindex="0"
>
Info
</span>
</span>
`;

exports[`EuiIconTip props type is rendered as the icon 1`] = `
<span
class="euiToolTipAnchor emotion-euiToolTipAnchor-inlineBlock"
id="id-wrapper"
>
<span
data-euiicon-type="warning"
tabindex="0"
>
Info
</span>
</span>
`;
Original file line number Diff line number Diff line change
@@ -1,36 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiToolTip anchor props are rendered 1`] = `
<body
class=""
>
<div>
<span
class="euiToolTipAnchor customAnchorClass1 emotion-euiToolTipAnchor-inlineBlock"
data-test-subj="DTS"
id="id-wrapper"
>
<button>
Trigger
</button>
</span>
</div>
</body>
`;

exports[`EuiToolTip display prop renders block 1`] = `
<div>
<span
class="euiToolTipAnchor emotion-euiToolTipAnchor-block"
id="id-wrapper"
>
<button>
Trigger
</button>
</span>
</div>
`;

exports[`EuiToolTip is rendered 1`] = `
<body
class=""
Expand All @@ -47,93 +16,3 @@ exports[`EuiToolTip is rendered 1`] = `
</div>
</body>
`;

exports[`EuiToolTip shows tooltip on mouseover and focus 1`] = `
<body
class="euiBody-hasPortalContent"
>
<div>
<span
class="euiToolTipAnchor emotion-euiToolTipAnchor-inlineBlock"
id="id-wrapper"
>
<button
aria-describedby="id"
data-test-subj="trigger"
>
Trigger
</button>
</span>
</div>
<div
data-euiportal="true"
>
<div
aria-label="aria-label"
class="euiToolTipPopover euiToolTip testClass1 testClass2 emotion-euiToolTip-top-euiTestCss"
data-position="top"
data-test-subj="test subject string"
id="id"
position="top"
role="tooltip"
style="top: -16px; left: -10px;"
>
<div
class="euiToolTip__title emotion-euiToolTip__title"
>
title
</div>
<div
class="euiToolTip__arrow emotion-euiToolTip__arrow-top"
style="left: 3px; top: 100%;"
/>
<div>
content
</div>
</div>
</div>
</body>
`;

exports[`EuiToolTip uses custom offset prop value 1`] = `
<body
class="euiBody-hasPortalContent"
>
<div>
<span
class="euiToolTipAnchor emotion-euiToolTipAnchor-inlineBlock"
id="generated-id-wrapper"
>
<button
aria-describedby="generated-id"
data-test-subj="trigger"
>
Trigger
</button>
</span>
</div>
<div
data-euiportal="true"
>
<div
aria-label="aria-label"
class="euiToolTipPopover euiToolTip testClass1 testClass2 emotion-euiToolTip-top-euiTestCss"
data-position="top"
data-test-subj="test subject string"
id="generated-id"
offset="32"
position="top"
role="tooltip"
style="top: -32px; left: -10px;"
>
<div
class="euiToolTip__arrow emotion-euiToolTip__arrow-top"
style="left: 3px; top: 100%;"
/>
<div>
content
</div>
</div>
</div>
</body>
`;
Loading