Fix: New tab opens with scroll position at top#862
Conversation
Add { preventScroll: true } to all focus() calls in the cursor
positioning system to prevent browser auto-scrolling behavior.
## Problem
When opening a new tab, the scroll position was not at the top
because element.focus() calls were causing the browser to auto-scroll
to the focused element.
## Solution
Add preventScroll option to focus() calls in:
- TextareaController.focus() - main entry point used by all controllers
- CursorPositioningService - direct textarea focus calls
- BaseNodeViewer - cursor restoration focus calls
This ensures:
- New tabs start with scroll at top (no saved scroll state)
- Tab switching preserves scroll position (restored from scroll-state store)
- Arrow navigation maintains scroll state during node-to-node movement
## Testing Notes
This change requires manual testing as unit tests use mocked DOM
that doesn't detect real browser focus/scroll behavior. Key scenarios:
- Enter key creates new node - cursor in new node
- Arrow up/down navigation between nodes
- Clicking on a node to edit
- Tab switching preserves scroll position
- New tab opens at scroll top
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code Review: PR #862 - Fix: New tab opens with scroll position at topReview Type: Initial Review Requirements Validation (Issue #860)
Code Review FindingsArchitectural AssessmentSummary: This is a well-scoped, surgical fix that addresses the root cause identified in the issue. The change follows the principle of least surprise by modifying the centralized focus mechanism rather than scattering fixes throughout the codebase. Design Quality:
:large_green_circle: Suggestions (Non-Blocking)1. Documentation Quality - Excellent
The inline comments clearly document the "why" (the three critical scenarios) rather than just the "what". This is exemplary documentation practice that will help future maintainers understand the rationale. 2. Comprehensive Coverage Verification I verified that all production
No orphaned 🟡 Important NotesManual Testing Required As correctly noted in the PR description, this change requires manual testing because:
The test plan provided in the PR description is comprehensive and covers the critical scenarios:
Security Assessment
Performance Assessment
Final Verdict: APPROVEThis is a clean, well-documented fix that:
The change is a clear net positive for code health with minimal risk. 🤖 Generated with Claude Code - Principal Engineer Review |
malibio
left a comment
There was a problem hiding this comment.
Review complete. Recommendation: APPROVE. This is a well-scoped fix that correctly addresses the root cause. See detailed review comment above.
Add { preventScroll: true } to all focus() calls in the cursor
positioning system to prevent browser auto-scrolling behavior.
## Problem
When opening a new tab, the scroll position was not at the top
because element.focus() calls were causing the browser to auto-scroll
to the focused element.
## Solution
Add preventScroll option to focus() calls in:
- TextareaController.focus() - main entry point used by all controllers
- CursorPositioningService - direct textarea focus calls
- BaseNodeViewer - cursor restoration focus calls
This ensures:
- New tabs start with scroll at top (no saved scroll state)
- Tab switching preserves scroll position (restored from scroll-state store)
- Arrow navigation maintains scroll state during node-to-node movement
## Testing Notes
This change requires manual testing as unit tests use mocked DOM
that doesn't detect real browser focus/scroll behavior. Key scenarios:
- Enter key creates new node - cursor in new node
- Arrow up/down navigation between nodes
- Clicking on a node to edit
- Tab switching preserves scroll position
- New tab opens at scroll top
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Add { preventScroll: true } to all focus() calls in the cursor
positioning system to prevent browser auto-scrolling behavior.
## Problem
When opening a new tab, the scroll position was not at the top
because element.focus() calls were causing the browser to auto-scroll
to the focused element.
## Solution
Add preventScroll option to focus() calls in:
- TextareaController.focus() - main entry point used by all controllers
- CursorPositioningService - direct textarea focus calls
- BaseNodeViewer - cursor restoration focus calls
This ensures:
- New tabs start with scroll at top (no saved scroll state)
- Tab switching preserves scroll position (restored from scroll-state store)
- Arrow navigation maintains scroll state during node-to-node movement
## Testing Notes
This change requires manual testing as unit tests use mocked DOM
that doesn't detect real browser focus/scroll behavior. Key scenarios:
- Enter key creates new node - cursor in new node
- Arrow up/down navigation between nodes
- Clicking on a node to edit
- Tab switching preserves scroll position
- New tab opens at scroll top
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Add { preventScroll: true } to all focus() calls in the cursor
positioning system to prevent browser auto-scrolling behavior.
## Problem
When opening a new tab, the scroll position was not at the top
because element.focus() calls were causing the browser to auto-scroll
to the focused element.
## Solution
Add preventScroll option to focus() calls in:
- TextareaController.focus() - main entry point used by all controllers
- CursorPositioningService - direct textarea focus calls
- BaseNodeViewer - cursor restoration focus calls
This ensures:
- New tabs start with scroll at top (no saved scroll state)
- Tab switching preserves scroll position (restored from scroll-state store)
- Arrow navigation maintains scroll state during node-to-node movement
## Testing Notes
This change requires manual testing as unit tests use mocked DOM
that doesn't detect real browser focus/scroll behavior. Key scenarios:
- Enter key creates new node - cursor in new node
- Arrow up/down navigation between nodes
- Clicking on a node to edit
- Tab switching preserves scroll position
- New tab opens at scroll top
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Summary
{ preventScroll: true }to allfocus()calls in the cursor positioning systemChanges
TextareaController.focus()method (main entry point)textarea.focus()callsTest plan
Note: Unit tests pass but manual testing is required as mocked DOM doesn't detect real browser focus/scroll behavior.
Closes #860
🤖 Generated with Claude Code