mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-21 00:03:52 +00:00
Refs #2381 - Dialogs: an editor opened behind a dialog (e.g. the new file's tab behind "Add File to Git") could take keyboard focus after the dialog opened, so Enter/Escape went to the editor. Dialogs now keep focus while they are the top layer. - Copy Reference failed with NotAllowedError: the WebView clipboard requires user activation, which native menu actions and async work (resolving the reference) outlive. Text copies now go through a native clipboard_write_text command (NSPasteboard / Win32 / GTK), and every navigator.clipboard.writeText caller uses the shared helper. The command is allowed in restricted (untrusted) projects like the other clipboard commands.
30 lines
1.4 KiB
TypeScript
30 lines
1.4 KiB
TypeScript
import { expect, openFromTree, test } from "./fixtures";
|
|
|
|
for (const key of ["Enter", "Escape"]) {
|
|
test(`confirmation keeps focus across a deferred editor focus until ${key}`, async ({ workbench: page }) => {
|
|
const editor = await openFromTree(page, "README.md");
|
|
const content = editor.locator(".cm-content");
|
|
await content.click();
|
|
const before = await content.innerText();
|
|
await page.evaluate(async () => {
|
|
const messages = "/src/workbench/messages.tsx";
|
|
const { confirm } = await import(/* @vite-ignore */ messages);
|
|
const content = document.querySelector<HTMLElement>(".cm-content")!;
|
|
void confirm({ title: "Add File to Git", message: "Add README.md?", ok: "Add" }).then((accepted: boolean) => {
|
|
document.body.dataset.confirmed = String(accepted);
|
|
});
|
|
requestAnimationFrame(() => {
|
|
content.focus();
|
|
document.body.dataset.focusAttempted = "true";
|
|
});
|
|
});
|
|
await expect(page.locator("body")).toHaveAttribute("data-focus-attempted", "true");
|
|
await expect(page.getByRole("button", { name: "Add", exact: true })).toBeFocused();
|
|
await page.keyboard.press(key);
|
|
await expect(page.getByRole("dialog", { name: "Add File to Git" })).toBeHidden();
|
|
await expect(page.locator("body")).toHaveAttribute("data-confirmed", String(key === "Enter"));
|
|
await expect(content).toBeFocused();
|
|
await expect(content).toHaveText(before!);
|
|
});
|
|
}
|