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(tooltip): close tooltips on prevented pointer move events #11557

Merged
merged 2 commits into from
Feb 14, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export default class TooltipManager {

private pointerMoveHandler = (event: PointerEvent): void => {
if (event.defaultPrevented) {
this.closeHoveredTooltip();
return;
}

Expand Down
29 changes: 29 additions & 0 deletions packages/calcite-components/src/components/tooltip/tooltip.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,35 @@ describe("calcite-tooltip", () => {
expect(await positionContainer.isVisible()).toBe(false);
});

it("should close when hover event is prevented", async () => {
const page = await newE2EPage();
await page.setContent(html`
<calcite-tooltip reference-element="ref">content</calcite-tooltip>
<div id="button-container">
<div id="ref">referenceElement</div>
</div>
`);
await skipAnimations(page);
await page.waitForChanges();

const positionContainer = await page.find(`calcite-tooltip >>> .${CSS.positionContainer}`);

const ref = await page.find("#ref");
await ref.hover();
await page.waitForTimeout(TOOLTIP_OPEN_DELAY_MS);
expect(await positionContainer.isVisible()).toBe(true);

await page.$eval("#button-container", (buttonContainer) => {
buttonContainer.addEventListener("pointermove", (event) => {
event.preventDefault();
});
});

await ref.hover();
await page.waitForTimeout(TOOLTIP_CLOSE_DELAY_MS);
expect(await positionContainer.isVisible()).toBe(false);
});

it("should honor hover interaction with span inside", async () => {
const page = await newE2EPage();

Expand Down
Loading