diff --git a/src/features/vcs/__tests__/logUiFeatures.test.tsx b/src/features/vcs/__tests__/logUiFeatures.test.tsx
index 8b8a2f3701..1e76cd912d 100644
--- a/src/features/vcs/__tests__/logUiFeatures.test.tsx
+++ b/src/features/vcs/__tests__/logUiFeatures.test.tsx
@@ -1,4 +1,5 @@
import type { Commit } from "@/bindings";
+import { getContext } from "@/platform/context";
import { ContextMenuHost, hideContextMenu } from "@/ui";
import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
@@ -157,6 +158,15 @@ describe("log controls", () => {
expect(useLogOptions.getState().collapseLinear).toBe(true);
});
+ it("gives the commit keys back when the focused list is removed", async () => {
+ const { unmount } = render();
+ const list = await screen.findByRole("listbox", { name: "Commits" });
+ act(() => list.focus());
+ expect(getContext().vcsLogCommitsFocus).toBe(true);
+ unmount();
+ expect(getContext().vcsLogCommitsFocus).toBe(false);
+ });
+
it("keeps the selected middle commit visible under collapse and supports speed search", async () => {
useLogOptions.setState({ collapseLinear: true });
useGitLog.setState({ selected: "/repo\0middle", selection: ["/repo\0middle"] });
diff --git a/src/features/vcs/log/CommitList.tsx b/src/features/vcs/log/CommitList.tsx
index 27572468c7..9c6747915b 100644
--- a/src/features/vcs/log/CommitList.tsx
+++ b/src/features/vcs/log/CommitList.tsx
@@ -96,7 +96,14 @@ export function CommitList({ fileHistory = false }: { fileHistory?: boolean }) {
const speedGeneration = useRef(0);
const speedTimer = useRef | undefined>(undefined);
useEffect(() => () => clearTimeout(speedTimer.current), []);
- useEffect(() => () => setContext("vcsLogRevisionFocus", false), []);
+ // React reports no blur for a focused list it removes.
+ useEffect(
+ () => () => {
+ setContext("vcsLogRevisionFocus", false);
+ setContext("vcsLogCommitsFocus", false);
+ },
+ [],
+ );
const columns = useMemo(() => {
const builtins: LogColumn[] = [
...(opts.showAuthor ? [{ id: "author", title: "Author", width: 130, render: (c: Commit) => c.author }] : []),