Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

The useAutoScroll hook's ResizeObserver callback was using an if (rafIdRef.current !== null) return guard for coalescing, but the stories were still seeing 1px scroll offsets during visual regression tests.

Changes

  • Use ??= operator for cleaner RAF coalescing in ResizeObserver callback
  • Simplify story helpers to use single RAF wait after message load
  • Remove complex multi-frame scroll stabilization from stories

The production code now properly coalesces all resize events within a frame into a single scroll operation, making scroll positions deterministic for visual regression testing.


Generated with mux • Model: anthropic:claude-opus-4-5 • Thinking: high

The useAutoScroll hook's ResizeObserver was setting scrollTop synchronously
on every resize event. During async content rendering (Shiki highlighting,
Mermaid diagrams, images), this caused multiple scrolls per frame with
slightly different scrollHeight values, leading to 1px scroll offset
flakiness in visual regression tests.

Changes:
- Add RAF coalescing to ResizeObserver callback in useAutoScroll
- Simplify story helpers to use a single RAF wait after message load
- Remove complex multi-frame scroll stabilization from stories
@ammario ammario merged commit bb0c0b3 into main Dec 21, 2025
20 checks passed
@ammario ammario deleted the storybook-73kg branch December 21, 2025 03:24
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.

2 participants