Skip to content

Fix sidebar story list scroll-into-view for off-screen selections#34

Merged
brianlovin merged 3 commits intomainfrom
brianlovin/sidebar-scroll-fix
Jan 28, 2026
Merged

Fix sidebar story list scroll-into-view for off-screen selections#34
brianlovin merged 3 commits intomainfrom
brianlovin/sidebar-scroll-fix

Conversation

@brianlovin
Copy link
Owner

Fixes the bug where navigating with j/k to a story that's off-screen doesn't automatically scroll it into view.

Root cause: Story items have variable heights due to text wrapping and optional domain lines. The previous implementation used a hardcoded itemHeight = 2 and calculated positions as index * (itemHeight + gap), which was inaccurate.

Solution: Use the actual rendered item's Y position and viewport height from the layout engine instead of calculating positions manually. This ensures accurate scroll-into-view behavior regardless of item heights.

🤖 Generated with Claude Code

brianlovin and others added 3 commits January 27, 2026 18:33
Use actual item positions from layout instead of hardcoded heights. Story items have variable heights due to text wrapping and optional domain lines, so calculating position as index * (itemHeight + gap) was incorrect. Now uses the rendered item's y position and viewport.height for accurate scroll calculations.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Tests verify that:
- Scrolls down when navigating to off-screen story
- Scrolls up when navigating back to off-screen story
- Does not scroll when story is already visible

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Add extra renderer.idle() and renderOnce() after navigation loops
to ensure scroll positions are fully applied before assertions.
This fixes timing issues that caused CI failures with older Bun versions.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@brianlovin brianlovin merged commit d34dc76 into main Jan 28, 2026
1 check passed
@brianlovin brianlovin deleted the brianlovin/sidebar-scroll-fix branch January 28, 2026 02:40
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