Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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: 4 additions & 0 deletions packages/eui/changelogs/upcoming/9624.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**Bug fixes**

- Fixed `EuiToolTip` showing on programmatic focus return, e.g. after closing a modal or a flyout.
Comment thread
mgadewoll marked this conversation as resolved.
Outdated
- Fixed `EuiToolTip` persisting on mouse-click focus. Tooltip now only persists on keyboard focus.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
render,
waitForEuiToolTipHidden,
waitForEuiToolTipVisible,
simulateFocusVisible,
} from '../../../test/rtl';
import { requiredProps as commonProps } from '../../../test';
import { shouldRenderCustomStyles } from '../../../test/internal';
Expand Down Expand Up @@ -245,6 +246,8 @@ describe('EuiButtonGroup', () => {
});

describe('tooltips', () => {
afterEach(() => jest.restoreAllMocks());

it('shows a tooltip on hover and focus', async () => {
const { getByTestSubject, getByRole } = render(
<EuiButtonGroup
Expand All @@ -268,6 +271,7 @@ describe('EuiButtonGroup', () => {
fireEvent.mouseOut(getByTestSubject('buttonWithTooltip'));
await waitForEuiToolTipHidden();

simulateFocusVisible(getByTestSubject('buttonWithTooltip'));
fireEvent.focus(getByTestSubject('buttonWithTooltip'));
await waitForEuiToolTipVisible();
fireEvent.blur(getByTestSubject('buttonWithTooltip'));
Expand Down Expand Up @@ -302,6 +306,7 @@ describe('EuiButtonGroup', () => {
fireEvent.mouseOut(getByTestSubject('buttonWithTooltip').parentElement!);
await waitForEuiToolTipHidden();

simulateFocusVisible(getByTestSubject('buttonWithTooltip'));
fireEvent.focus(getByTestSubject('buttonWithTooltip'));
await waitForEuiToolTipVisible();
fireEvent.blur(getByTestSubject('buttonWithTooltip'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
render,
waitForEuiToolTipHidden,
waitForEuiToolTipVisible,
simulateFocusVisible,
} from '../../test/rtl';

import { EuiColorPickerSwatch } from './color_picker_swatch';
Expand All @@ -28,6 +29,8 @@ describe('EuiColorPickerSwatch', () => {
});

describe('showToolTip', () => {
afterEach(() => jest.restoreAllMocks());

test('it renders a color label tooltip on hover', async () => {
const { getByTestSubject, getByText } = render(
<EuiColorPickerSwatch
Expand Down Expand Up @@ -61,6 +64,7 @@ describe('EuiColorPickerSwatch', () => {

const swatchElement = getByTestSubject('color-picker-swatch');

simulateFocusVisible(swatchElement);
fireEvent.focus(swatchElement);

await waitForEuiToolTipVisible();
Expand Down
4 changes: 4 additions & 0 deletions packages/eui/src/components/color_picker/hue.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
render,
waitForEuiToolTipHidden,
waitForEuiToolTipVisible,
simulateFocusVisible,
} from '../../test/rtl';

import { EuiHue } from './hue';
Expand All @@ -23,6 +24,8 @@ const onChange = () => {
};

describe('EuiHue', () => {
afterEach(() => jest.restoreAllMocks());

shouldRenderCustomStyles(<EuiHue onChange={onChange} />, {
skip: { style: true },
});
Expand Down Expand Up @@ -81,6 +84,7 @@ describe('EuiHue', () => {

const thumbElement = document.querySelector('.euiHue__range')!;

simulateFocusVisible(thumbElement);
fireEvent.focus(thumbElement);

await waitForEuiToolTipVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
render,
waitForEuiToolTipHidden,
waitForEuiToolTipVisible,
simulateFocusVisible,
} from '../../test/rtl';

import { EuiSaturation } from './saturation';
Expand All @@ -23,6 +24,8 @@ const onChange = () => {
};

describe('EuiSaturation', () => {
afterEach(() => jest.restoreAllMocks());

shouldRenderCustomStyles(<EuiSaturation onChange={onChange} />);

test('is rendered', () => {
Expand Down Expand Up @@ -70,6 +73,7 @@ describe('EuiSaturation', () => {

const thumbElement = document.querySelector('.euiSaturation__indicator')!;

simulateFocusVisible(thumbElement);
fireEvent.focus(thumbElement);

await waitForEuiToolTipVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ describe('EuiTableHeaderCell', () => {
'info'
);

fireEvent.focus(getByTestSubject('icon'));
fireEvent.mouseOver(getByTestSubject('icon'));
await waitForEuiToolTipVisible();

expect(getByTestSubject('tooltip')).toHaveTextContent(
Expand Down Expand Up @@ -312,7 +312,7 @@ describe('EuiTableHeaderCell', () => {
'info'
);

fireEvent.focus(getByTestSubject('tableHeaderSortButton'));
fireEvent.mouseOver(getByTestSubject('tableHeaderSortButton'));
await waitForEuiToolTipVisible();

expect(getByTestSubject('tooltip')).toHaveTextContent(
Expand Down
10 changes: 5 additions & 5 deletions packages/eui/src/components/tool_tip/tool_tip.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ describe('EuiToolTip', () => {
);
cy.get('[data-test-subj="tooltip"]').should('not.exist');

cy.get('[data-test-subj="toggleToolTip"]').focus();
cy.realPress('Tab');
cy.get('[data-test-subj="tooltip"]').should('exist');

cy.get('[data-test-subj="toggleToolTip"]').blur();
cy.realPress('Tab');
cy.get('[data-test-subj="tooltip"]').should('not.exist');
Comment thread
weronikaolejniczak marked this conversation as resolved.
});

Expand All @@ -82,10 +82,10 @@ describe('EuiToolTip', () => {
);
cy.get('[data-test-subj="tooltip"]').should('not.exist');

cy.get('[data-test-subj="toggleToolTip"]').focus();
cy.realPress('Tab');
cy.get('[data-test-subj="tooltip"]').should('exist');

cy.get('[data-test-subj="toggleToolTip"]').blur();
cy.realPress('Tab');
cy.get('[data-test-subj="tooltip"]').should('not.exist');
});

Expand All @@ -102,7 +102,7 @@ describe('EuiToolTip', () => {
);
cy.get('[data-test-subj="tooltip"]').should('not.exist');

cy.get('[data-test-subj="toggleToolTipA"]').focus();
cy.realPress('Tab');
cy.contains('Tooltip A').should('exist');
cy.contains('Tooltip B').should('not.exist');

Expand Down
Loading