mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-07 10:16:03 -10:00
fix(ui): start pointer drags only while the primary button is held (#1071)
On macOS, with an editable element focused and an input method active, WebKit can deliver a tap as pointerup then pointerdown, so drag trackers saw every later pointermove as a held button: one tap plus a pointer move started a phantom drag (file drag label, tab detach, tool window move) and the next tap dropped it. A drag now starts only from a move with the primary button down, a move without it cancels the press, and late button-less moves after a drag started are ignored so the drop is kept. Resizers, dialog drag/resize, pan and the review gutter end instead; the Project view also listens for pointercancel. Refs #760 Co-authored-by: ntbang0901 <[email protected]>
This commit is contained in:
1 parent
a35e434376
commit
555226a9bf
15 files changed
+180
-9
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("keyboard navigation: arrows move, Right/Left expand and collapse, Enter opens", async ({ workbench: page }) => {
|
||||
@@ -48,3 +49,43 @@ test("Git ignore submenu offers shared and local destinations for files and fold
|
||||
await page.keyboard.press("Escape");
|
||||
}
|
||||
});
|
||||
|
||||
// macOS WebKit can deliver a tap's pointerup before its pointerdown, leaving a press with no button held (#760).
|
||||
const settle = (page: Page) =>
|
||||
page.evaluate(() => new Promise((done) => requestAnimationFrame(() => requestAnimationFrame(done))));
|
||||
|
||||
async function fileRow(page: Page) {
|
||||
// The start-up splash swallows raw mouse presses until it has faded out.
|
||||
await expect(page.locator("#splash")).toHaveCount(0);
|
||||
const file = page.getByRole("tree", { name: "Project" }).getByRole("treeitem", { name: "settings.gradle.kts" });
|
||||
await file.scrollIntoViewIfNeeded();
|
||||
const content = file.locator("[data-project-path]");
|
||||
const box = (await content.boundingBox())!;
|
||||
return {
|
||||
content,
|
||||
x: box.x + 10,
|
||||
y: box.y + box.height / 2,
|
||||
dragLabel: page.locator('body > div[aria-hidden="true"]', { hasText: "settings.gradle.kts" }),
|
||||
};
|
||||
}
|
||||
|
||||
test("a press without a held button never starts a file drag", async ({ workbench: page }) => {
|
||||
const { content, x, y, dragLabel } = await fileRow(page);
|
||||
await content.evaluate((el) =>
|
||||
el.dispatchEvent(new PointerEvent("pointerdown", { bubbles: true, button: 0, buttons: 0, pointerType: "mouse" })),
|
||||
);
|
||||
await page.mouse.move(x, y);
|
||||
await page.mouse.move(x + 60, y + 30, { steps: 5 });
|
||||
await settle(page);
|
||||
await expect(dragLabel).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("a real mouse drag still shows the drag label until release", async ({ workbench: page }) => {
|
||||
const { x, y, dragLabel } = await fileRow(page);
|
||||
await page.mouse.move(x, y);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(x + 60, y + 30, { steps: 5 });
|
||||
await expect(dragLabel).toHaveCount(1);
|
||||
await page.mouse.up();
|
||||
await expect(dragLabel).toHaveCount(0);
|
||||
});
|
||||
Reference in new issue
Block a user