The best way to control Claude Code, Codex and more from any computer or phone
fix(web): scrolling a PR description no longer moves focus to the condensed header (#39840)
Julius Marminge committed
Nov 20, 2026 at 10:54 UTC
e668e6141faef533509e1d38d0f984bb38431d3f
4 files changed
+54
-6
apps/web/src/components/pullRequest/PullRequestDetailCrumbs.tsx
+2
@@ -131,6 +131,7 @@ export function PullRequestDetailCrumbs({
131
<div
132
aria-hidden={condensed}
133
inert={condensed}
134
+ data-workspace-scroll-swap
135
className={cn(
136
ROW_CLASS_NAME,
137
condensed
@@ -177,6 +178,7 @@ export function PullRequestDetailCrumbs({
178
<div
179
aria-hidden={!condensed}
180
inert={!condensed}
181
+ data-workspace-scroll-swap
182
className={cn(
183
ROW_CLASS_NAME,
184
condensed
apps/web/src/components/pullRequest/PullRequestDetailPanel.permissions.browser.test.tsx
+48
-6
@@ -8,12 +8,14 @@ import {
8
} from "@t3tools/contracts";
9
import { expect, it, vi } from "vite-plus/test";
10
import { userEvent } from "vite-plus/test/browser";
11
+import appCss from "~/index.css?inline";
12
import { DraftId, useComposerDraftStore } from "~/composerDraftStore";
13
import { act, fakeTimers, render } from "../../../test/render";
14
14
-const { permissions, reads } = vi.hoisted(() => ({
15
+const { permissions, reads, shown } = vi.hoisted(() => ({
16
permissions: { checkout: true, operate: true },
17
reads: { diff: [] as unknown[] },
18
+ shown: { detail: null as PullRequestDetailView | null },
19
}));
20
21
vi.mock(import("~/state/session"), async (original) => ({
@@ -38,9 +40,9 @@ vi.mock(import("./usePullRequestDetail"), async (original) => ({
40
detailQuery: { isPending: false, refresh: vi.fn() },
41
activityQuery: { isPending: false, refresh: vi.fn(), error: null },
42
activity: null,
41
- sharedSummary: detail,
42
- coreDetail: detail,
43
- detail,
43
+ sharedSummary: shown.detail,
44
+ coreDetail: shown.detail,
45
+ detail: shown.detail,
46
})) as never,
47
}));
48
vi.mock(import("~/state/usePullRequestStack"), async (original) => ({
@@ -71,6 +73,7 @@ vi.mock(import("~/state/use-atom-command"), async (original) => ({
73
useAtomCommand: (() => vi.fn()) as never,
74
}));
75
76
+import { createWorkspaceFocusController, workspaceAreaProps } from "~/lib/workspaceFocus";
77
import { PullRequestDetailPanel } from "./PullRequestDetailPanel";
78
79
const detail: PullRequestDetailView = {
@@ -127,10 +130,10 @@ const detail: PullRequestDetailView = {
130
131
const environmentId = EnvironmentId.make("environment");
132
const draftId = DraftId.make("conflicts-draft");
130
-const panel = (attach = false) => (
133
+const panel = (attach = false, reference = detail) => (
134
<PullRequestDetailPanel
135
environmentId={environmentId}
133
- reference={detail}
136
+ reference={reference}
137
context="page"
138
shortcutsEnabled={false}
139
getShortcutContext={() => ({
@@ -149,6 +152,7 @@ function setup() {
152
permissions.checkout = true;
153
permissions.operate = true;
154
reads.diff = [];
155
+ shown.detail = detail;
156
useComposerDraftStore.setState({ draftsByThreadKey: {} });
157
}
158
@@ -196,3 +200,41 @@ it("reads the first diff page once the pointer rests on the Code tab", async ()
200
input: { projectId: detail.projectId, repository: detail.repository, number: detail.number },
201
});
202
});
203
+
204
+it("keeps a screen reader's place when scrolling the description condenses the header", async () => {
205
+ setup();
206
+ shown.detail = {
207
+ ...detail,
208
+ body: Array.from({ length: 80 }, (_, line) => `Line ${line}`).join("\n\n"),
209
+ };
210
+ const style = document.createElement("style");
211
+ style.textContent = appCss;
212
+ document.head.append(style);
213
+ using _style = { [Symbol.dispose]: () => style.remove() };
214
+ const controller = createWorkspaceFocusController(document);
215
+ using _controller = { [Symbol.dispose]: () => controller.dispose() };
216
+ await using screen = await render(
217
+ <div {...workspaceAreaProps("pull-requests", 1)} className="flex h-[600px] flex-col">
218
+ {panel()}
219
+ </div>,
220
+ );
221
+ const openOnHost = screen.getByRole("button", { name: "Open pull request #1 on host" });
222
+ await expect.element(openOnHost).toBeVisible();
223
+ const expanded = openOnHost.element() as HTMLButtonElement;
224
+ expanded.focus();
225
+ await expect.element(screen.getByText("Line 79")).toBeInTheDocument();
226
+ let scroller = screen.getByText("Line 79").element().parentElement;
227
+ while (scroller && getComputedStyle(scroller).overflowY !== "auto") {
228
+ scroller = scroller.parentElement;
229
+ }
230
+ using _timers = fakeTimers();
231
+ using moves = vi.spyOn(HTMLElement.prototype, "focus");
232
+ // Browse mode scrolls a heading into view without moving DOM focus.
233
+ await act(() => {
234
+ scroller!.scrollTop = scroller!.scrollHeight;
235
+ });
236
+ await vi.waitFor(() => expect(expanded.closest("[inert]")).not.toBeNull());
237
+ await act(() => vi.advanceTimersToNextFrame());
238
+ // A programmatic focus() pulls the screen reader's browse cursor back to the header.
239
+ expect(moves).not.toHaveBeenCalled();
240
+});
apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx
+2
@@ -1705,6 +1705,7 @@ export function PullRequestDetailPanel({
1705
: "translate-y-1 opacity-0 duration-100",
1706
)}
1707
inert={!condensed}
1708
+ data-workspace-scroll-swap
1709
>
1710
{detail ? (
1711
<div className="col-span-2 min-w-0 px-4 pb-2 pt-1">
@@ -1794,6 +1795,7 @@ export function PullRequestDetailPanel({
1795
: "translate-y-0 opacity-100 delay-50",
1796
)}
1797
inert={condensed}
1798
+ data-workspace-scroll-swap
1799
>
1800
{detail ? (
1801
<PullRequestDetailHeaderBody
apps/web/src/lib/workspaceFocus.ts
+2
@@ -298,6 +298,8 @@ export function createWorkspaceFocusController(doc: Document) {
298
if (
299
doc.activeElement !== doc.body ||
300
!doc.hasFocus() ||
301
+ // Scrolling swaps these out; focusing elsewhere would pull a screen reader's cursor along.
302
+ lost.closest("[inert][data-workspace-scroll-swap]") ||
303
(isWorkspaceElementVisible(lost) && !lost.matches(":disabled"))
304
)
305
return;