Files
buzz/desktop/src
npub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6w a8b2159722 fix(timeline): anchor virtualizer with scrollMargin for content above the list
Fixes two loading-state jank symptoms tho flagged on the main timeline, both
the same root cause.

Root cause: the scroll container holds content ABOVE the virtualized list inside
the SAME scrollable element — the pagination sentinel, the load-older spinner,
and the channel/DM intro banner. @tanstack/react-virtual positions items at
paddingStart + scrollMargin and defaults scrollMargin to 0, so it assumed row 0
sat at scrollTop 0 when it actually painted lower by the above-content height.
That offset mismatch produced:
  - the header/list 'sandwich' (freshly-loaded rows wedging into the seam between
    the intro/spinner and the list)
  - viewport drift while rows filled above + below (the anchor math was off by a
    variable above-content height)

Fix: measure the list's offset within the scroll container and feed it as the
virtualizer's scrollMargin (useVirtualScrollMargin — re-measures on a
ResizeObserver + when the intro/spinner/list visibility changes). Rows are now
positioned at virtualItem.start - scrollMargin within the spacer, which sits at
that offset, so item offsets line up with where they paint regardless of what's
above. The intro banner stays a sibling above the list and is only visible at
the very top, as intended; native key-stable prepend retention now holds steady
because the offset origin is correct.

Main timeline only; thread pane untouched. Adds a DOM test locking in the
start - scrollMargin positioning.

Co-authored-by: Taylor Ho <taylorkmho@gmail.com>
Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
2026-06-15 21:16:46 -07:00
..
2026-06-15 21:58:12 +01:00