Skip to content

feat(data-log): stable item key for live anchor + scroll-to-top button#39

Merged
IamShobe merged 2 commits into
mainfrom
fix/sticky-row-overlap
Mar 13, 2026
Merged

feat(data-log): stable item key for live anchor + scroll-to-top button#39
IamShobe merged 2 commits into
mainfrom
fix/sticky-row-overlap

Conversation

@IamShobe

Copy link
Copy Markdown
Owner

Summary

  • Fix live scroll anchor movement: getItemKey now keys TanStack Virtual's size cache by log ID instead of index. After a live prepend, existing measurements (including open detail panels) are immediately accurate — no ResizeObserver correction cycles, no visible scroll jumps.
  • Simplify Step 2: reads anchorItem.start directly instead of estimating delta * 35, since measurements are now accurate from the first render.
  • Scroll-to-top button: floating button in the top-right corner of the log view, visible when scrolled more than 200 px. Uses react-use's useScroll for tracking. Jumps scrollTop to 0 instantly (smooth scroll breaks with virtualization due to mid-scroll re-renders).

Test plan

  • CI: lint / format / tests / typecheck all pass
  • Open a log with a long details panel, scroll deep, trigger a live fetch — viewport should not move
  • Scroll down > 200 px — scroll-to-top button appears top-right; click it — jumps to top instantly
  • Scroll-to-top button disappears when at the top

…logs

Replace the 2-virtual-slots-per-log approach with a single slot per log.
Each virtual item now contains an inner sticky DataRow header and a
RowDetails panel below it. Using `top` instead of `transform` on the
outer wrapper ensures `position: sticky` works correctly relative to
the scroll container.

Removes: activeStickyIndexRef, isSticky/isActiveSticky helpers,
custom rangeExtractor, and useIsLogOpen usage in DataLog.
Key live scroll anchor with log ID via getItemKey so TanStack Virtual's
size cache survives prepends. Eliminates ResizeObserver correction cycles
and visible scroll jumps when expanded detail panels are in view.

Step 2 now reads anchorItem.start directly instead of estimating
delta * 35, since measurements are accurate immediately after prepend.

Add a scroll-to-top button (top-right, visible when scrolled > 200 px)
that jumps scrollTop to 0 instantly to avoid virtualization mid-scroll
issues. Uses react-use useScroll for scroll position tracking.
@IamShobe
IamShobe merged commit 333577b into main Mar 13, 2026
3 checks passed
@IamShobe
IamShobe deleted the fix/sticky-row-overlap branch March 13, 2026 14:51
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.

1 participant