Skip to content

fix(platform): scroll a task's thread by trackpad in the board dialog - #4863

Merged
yannickmonney merged 5 commits into
mainfrom
fix/task-view-scroll
Oct 12, 2026
Merged

yannickmonney merged 5 commits into
mainfrom
fix/task-view-scroll

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4792.

Cause

The board's task dialog is a modal Radix dialog, and its scroll lock (react-remove-scroll) cancels an upward wheel or touch unless the scrollport under the pointer has room above: it reads scrollTop > 0 as room. The thread column was a column-reverse scrollport, which rests at scrollTop 0 and scrolls into negative offsets, so every upward gesture over the open task was cancelled. The lock only intercepts wheel and touch events, so the keyboard and the scrollbar still moved the thread — hence "with a trackpad" (macOS hides overlay scrollbars). It was the only column-reverse scrollport in the app.

Reproduced on the board's dialog in Chromium and in Playwright's WebKit: a wheel of -300 left the thread where it was (in Chromium the event reached window already cancelled, defaultPrevented: true). The same wheel on the standalone task page scrolled the thread (checked in Chromium).

Fix

TaskThreadColumn is an ordinary scrollport now, held on its newest end by a new useThreadScroll hook:

  • it opens on the newest end and follows the thread and its own box (a comment arriving, the task loading in, the composer growing or shrinking, the window resizing) while the reader is at the end;
  • a reader who scrolls up is left where they are, and scrolling back down to within a few lines of the end follows again. A reader's scroll moves the offset and the distance to the end in opposite directions (up and farther, down and nearer), and an event for an offset the column already looked at is its own pin and is ignored;
  • the browser's own scroll anchoring is switched off on the scrollport while the thread follows the end, and on while the reader reads. On a task with more than a page of comments, each new comment drops the oldest row off the top as it joins the end, and the browser anchors the row that left: it moves the offset by that row's height, an event that looks exactly like the reader scrolling up, so the thread stopped following and a posted comment landed partly below the fold (80px out of view on the 60-comment QA task, 64px in the test). Where the thread's height nets out, nothing in the offset and the height tells the two apart, so the cause is removed instead: the column pins the end itself, and the switch is a class so it never fights the history load's inline one;
  • where the browser has no scroll anchoring (Safari), it moves the scrollport by how far a row above the reader really changed height (an image arriving, a resize), so what is read does not jump, and it stands down while a history load holds the place itself (HELD_SCROLLPORTS, beside useTaskHistoryAnchor).

The conversation's rows skip layout (content-visibility) only where the browser anchors scrolling, from one definition in lib/lazy-layout.ts instead of three spellings. A row drawn for the first time rarely has the height that was guessed for it and everything under it moves; Chromium and Firefox hold the reader still, and Safari showed every such row as a jump (34 of 60 wheel notches in WebKit with a plain ordinary scrollport). Making the thread correct that by script would have written scrollTop as rows near the reader, which on a touch screen can cut a flick. In Safari every row is laid out in full instead: relaying out a 61-row thread took about 5 ms in WebKit against 1 ms with rows skipped, and longer histories scale with the rows loaded.

The reversed scrollport had a Safari jump of its own, which this also removes: a comment arriving at the end while you read above moved the row being read by 224px in WebKit with the old column, and by 0 with the new one (0 in Chromium with both).

I did not use use-stick-to-bottom: it follows the content only (not the scrollport's own box), animates by default and registers document listeners when imported, and does not hold a reader's place in Safari.

Verified

  • Real Chromium (vitest browser, 24 tests on the column and 6 on the conversation): a real wheel scrolls the thread up and back down in a modal dialog hosted like the board's and on the page; the column opens on the newest end, starts a short thread at the top, keeps the composer in view, follows growth and its own box changing, stays on the end when a new comment drops the oldest row, leaves a reader who scrolled up alone (all the way up, a screen above the end, a few lines up while a row above grows, and while the last row keeps growing), follows again within a few lines of the end, ignores its own pin's scroll event and a scroll toward the end that arrives with more thread, switches anchoring off while following and on while reading, and holds what is read still when a row above grows, both where the browser anchors and in Safari's way (support question answered no, native anchoring off), also beside the real "Show earlier comments" load. Tests that wait out a wheel wait for the scrollport to stop moving, and the ones that assert nothing moved wait a whole frame, resize observers included.
  • Eleven rules of the hook were broken in turn (never leave the end, leave on distance alone, never rejoin, rejoin without direction, ignore the scrollport's own box, ignore content growth, no pin on mount, no place-holding, no stand-down, anchoring never switched off, anchoring always off) and a test went red every time. Two survived the first attempt and got a test each.
  • Against a dev stack, real wheel input, in Chromium and Playwright's WebKit: the dialog and the page open on the newest end, scrolling up through a 60-comment thread in notches of 40 and 120px never moves the row being read off its notch, loading earlier comments keeps the row being read in place, a row arriving at the end does not move a scrolled-up reader, a comment posted while reading at the top leaves the place alone, and one posted at the end stays on the end, on the 60-comment task too, where it had stopped 80px short. Sampled after the hook's pin and before paint, every frame that holds rows is already on the end, on both surfaces in both engines. The dialog's details panel and the phone drawer scroll as before.
  • oxlint, oxfmt, tsc, knip, lint:manual and check-guide on the tasks suite; the tasks browser suite (119 tests) and the tasks, projects, home, routes and chat jsdom suites (2008 tests).
  • New manual box TASK-F92, and an automation row for what the browser specs own.

Not covered

  • A real Safari under a trackpad, and iOS: WebKit's engine only. The column still writes scrollTop when something above the reader really changes height, which on a touch device may cut a flick; I could not measure that, and TASK-F92 asks for an iPhone and an iPad flick. The reversed column needed no script for upward scrolling there. Firefox did not run (the installed Playwright build did not match).

The board's task dialog locks the page's scroll, and the lock cancels an
upward wheel or touch unless the scrollport under it has room above: it
reads `scrollTop` above 0 as room. The thread column was a
`column-reverse` scrollport, which rests at `scrollTop` 0 and scrolls
into negative offsets, so every upward gesture over the thread was
cancelled. The lock only intercepts wheel and touch events, so a
trackpad could not scroll the open task at all.

The column is an ordinary scrollport now, held on its newest end by
`useThreadScroll`: it opens there, follows the thread and its own box
while the reader is at the end, and leaves a reader who scrolled up
where they are. Safari has no scroll anchoring, which the reversed
scrollport made unnecessary by growing upward, so there the hook also
moves the scrollport by how far a row above the reader changed height (a
row skipped by `content-visibility` is drawn at its real height as it
nears). It stands down while a history load holds the place itself.

Tests drive a real wheel in a dialog hosted like the board's, and the
column's follow, hold and place-holding rules, in real Chromium. The
history tests now read the conversation in the real column.
A resize observer runs after a frame's animation callbacks, so a test
that waited one frame and then asserted the thread had held still read
before the column's own observer had its turn, and would have passed
whatever the column did. The tests now wait for two frames, as the
conversation's tests already do.

Two more cases cover the rule that a reader within a few lines of the
end follows the thread again, and that one a screen above it is left
where they are. Breaking each rule of `useThreadScroll` in turn turns a
test red.
The rows of a task's conversation skip layout and paint until they near
the viewport, and keep the height they last had. A row drawn for the
first time rarely has the height that was guessed for it, and everything
under it moves. Chromium and Firefox anchor scrolling and hold what the
reader is reading still; Safari does not, so every such row was a jump,
and the thread moved the scrollport by script while a flick was under
way, which on a touch screen can cut the flick.

The rows now skip layout only where `overflow-anchor` is supported, from
one definition in `lib/lazy-layout.ts` instead of three spellings. In
Safari every row is laid out in full: relaying out a 61-row thread took
about 5 ms there against 1 ms with rows skipped. The thread no longer
needs to move the scrollport as rows near the reader, only when
something above them really changes, such as an image arriving.

Opening the page in WebKit also lands on the end in one step; with the
rows' first guess it painted a frame of mid-thread first.
The thread took any scroll event that did not move up, within 48px of
the end, for the reader coming back to it. Two things produce such
events without the reader: the browser anchoring when a row above grows,
and the column's own correction. A reader who had scrolled up a few lines
was pulled back to the end by the next arrival.

A reader's scroll moves the offset and the distance to the end in
opposite directions, up and farther or down and nearer. Anchoring and the
column's correction move the offset and the end together and leave the
distance alone, and a browser giving back an offset it had clamped moves
it toward the end while the thread has grown, so the distance grows too.
Leaving and rejoining the end now need both signals, and an event for an
offset already looked at is ignored. Reading the distance alone was
tried first and took the restored offset for a reader scrolling away.

New tests cover a reader nudged up a few lines while a row above grows
(both where the browser anchors and in Safari's way), the scrollport
growing under a reader at the end, a scroll event its own pin queued
arriving after more thread did, and the Safari path beside the real
history load. Tests that wait out a wheel now wait for the scrollport to
stop moving, and the one that asserts nothing moved reads a row that is
in view.
On a task with more than a page of comments, a new comment drops the
oldest row off the top as it joins the end. The browser anchors the row
that left and moves the offset by its height, a scroll event that looks
exactly like a reader scrolling up, and the thread stopped following:
posting a comment on a long task left the end 80px out of view, with the
new comment partly below the fold. Where the thread's height happens to
net out the offset change is the only thing in the event, so no reading
of the offset and the height can tell the two apart.

Native anchoring is now switched off on the scrollport while the thread
follows the end, which the thread pins itself, and on while the reader
reads, when it holds their place. A class carries the switch so it never
fights the history load's inline one. Without anchoring while following,
the only scroll events are the reader's, the thread's own, and a clamp
that lands on the end.

An input-timing rule was tried first and dropped: a scroll that comes
with a wheel, a key, a touch or a press counts as the reader's. It
could not separate the anchoring event from a reader's scroll in a frame
where the thread also changed size, and it would have let find-in-page
or a screen reader be pulled back to the end.

New tests cover a new comment dropping the oldest row (both where the
browser anchors and in Safari's way), a reader who scrolls up while the
last row keeps growing, the anchoring switch itself, and a scroll toward
the end that arrives with more thread. Breaking each of eleven rules of
the hook in turn turns a test red.
@yannickmonney
yannickmonney added this pull request to the merge queue Oct 12, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 12, 2026
@yannickmonney
yannickmonney added this pull request to the merge queue Oct 12, 2026
Merged via the queue into main with commit db826c8 Oct 12, 2026
@yannickmonney
yannickmonney deleted the fix/task-view-scroll branch October 12, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Opening a task makes the task view impossible to scroll with a trackpad

1 participant