Skip to content

Commit ba8708d

Browse files
chore(flyout): test escape key down behavior with tooltip as content
1 parent 44999b3 commit ba8708d

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

packages/eui/src/components/flyout/flyout.spec.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import React, { useState } from 'react';
1515
import { EuiGlobalToastList } from '../toast';
1616
import { EuiHeader } from '../header';
1717
import { EuiFlyout } from './flyout';
18+
import { EuiToolTip } from '../tool_tip';
19+
import { EuiButton } from '../button';
1820

1921
const childrenDefault = (
2022
<>
@@ -92,6 +94,46 @@ describe('EuiFlyout', () => {
9294
});
9395
});
9496

97+
describe('Close behavior: overlay elements as children', () => {
98+
it('closes the flyout when the EuiToolTip is not focused', () => {
99+
cy.mount(
100+
<Flyout>
101+
<EuiToolTip content="Tooltip text here" data-test-subj="tool_tip">
102+
<EuiButton data-test-subj="tool_tip_trigger">
103+
Show tooltip
104+
</EuiButton>
105+
</EuiToolTip>
106+
</Flyout>
107+
);
108+
cy.get('[data-test-subj="tool_tip"]').should('not.exist');
109+
110+
cy.realPress('Escape');
111+
cy.get('[data-test-subj="flyoutSpec"]').should('not.exist');
112+
});
113+
114+
it('does not close the flyout when the tooltip is shown but closes the tooltip', () => {
115+
cy.mount(
116+
<Flyout
117+
children={
118+
<EuiToolTip content="Tooltip text here" data-test-subj="tool_tip">
119+
<EuiButton data-test-subj="tool_tip_trigger">
120+
Show tooltip
121+
</EuiButton>
122+
</EuiToolTip>
123+
}
124+
></Flyout>
125+
);
126+
cy.get('[data-test-subj="tool_tip"]').should('not.exist');
127+
128+
cy.repeatRealPress('Tab', 2);
129+
cy.get('[data-test-subj="tool_tip"]').should('exist');
130+
131+
cy.realPress('Escape');
132+
cy.get('[data-test-subj="tool_tip"]').should('not.exist');
133+
cy.get('[data-test-subj="flyoutSpec"]').should('exist');
134+
});
135+
});
136+
95137
describe('Close behavior: outside clicks', () => {
96138
// We're using toasts here to trigger outside clicks, as a UX case where
97139
// we would generally expect toasts overlaid on top of a flyout *not* to close the flyout

0 commit comments

Comments
 (0)