дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 09:11:10 +02:00
fix(vcs): focus the diff's text when the modal diff window opens (#7252)
Under the modal commit interface the diff window gave initial focus to its toolbar's first button, so F7 / Shift+F7 did nothing until a click in the text. The dialog body is now the autofocus target and an editor focus host, handing focus to the diff's text. Closes #7250 Co-authored-by: formiat <[email protected]>
Цей коміт міститься в:
1 джерело
d73b8d8ec1
коміт
63c2ced086
2 files changed
+33
No files matched your search
@@ -523,6 +523,34 @@ test("Git Log file selection stays in place and opens a diff on activation", asy
|
||||
await expect(firstDiff).toHaveAttribute("aria-selected", "true");
|
||||
});
|
||||
|
||||
test("a Git Log file's diff window under the modal commit interface takes focus: F7 works at once", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.evaluate(async () => {
|
||||
const h = window.__ipc.handlers;
|
||||
h.vcs_commit_files = () => [{ path: "src/orders.ts", kind: "modified", oldPath: null }];
|
||||
// Two differences far apart, so F7 has somewhere to go.
|
||||
h.vcs_file_at = ({ rev }) => {
|
||||
const lines = Array.from({ length: 80 }, (_, i) => `const step${i} = ${i};`);
|
||||
if (rev === "0".repeat(40)) for (const i of [5, 60]) lines[i] = `const step${i} = ${i} * 2;`;
|
||||
return `${lines.join("\n")}\n`;
|
||||
};
|
||||
const projectModule = "/src/platform/project.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ projectModule);
|
||||
const settings = structuredClone(useProject.getState().settings ?? {}) as Record<string, Record<string, unknown>>;
|
||||
settings.vcs = { ...settings.vcs, commit: { ...(settings.vcs?.commit as object), nonModal: false } };
|
||||
useProject.setState({ settings: settings as never });
|
||||
});
|
||||
await page.getByRole("listbox", { name: "Commits" }).getByRole("option").first().click();
|
||||
await page.getByRole("tree", { name: "Changed files" }).getByRole("treeitem", { name: "orders.ts" }).dblclick();
|
||||
const dialog = page.getByRole("dialog", { name: /^orders\.ts/ });
|
||||
await expect(dialog.getByText("1 of 2 differences", { exact: true })).toBeVisible();
|
||||
// The diff's text has focus, not the toolbar's first button.
|
||||
await expect(dialog.locator(".cm-editor.cm-focused")).toHaveCount(1);
|
||||
await page.keyboard.press("F7");
|
||||
await expect(dialog.getByText("2 of 2 differences", { exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
test("Not Cherry-Picked Commits dims other rows while keeping unpicked commits readable", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
|
||||
@@ -118,6 +118,11 @@ export function DiffDialogFrame({
|
||||
<div
|
||||
ref={body}
|
||||
className="vcsDiffDialogBody"
|
||||
// Focus the body, not the toolbar's first button: like an editor tab's host, it hands focus
|
||||
// to the diff's text, so F7 and the other diff keys work at once.
|
||||
data-autofocus=""
|
||||
data-editor-focus=""
|
||||
tabIndex={-1}
|
||||
// The dialog body is not a flex container: fill it so the editors reach the footer.
|
||||
style={{ display: "flex", flexDirection: "column", height: "100%", minHeight: 0 }}
|
||||
>
|
||||
|
||||
Reference in new issue
Заблокувати користувача