Problem
When opening a new tab to view a root node, the scroll position is not at the top of the document. Users have to manually scroll up to see the beginning of the content.
Root Cause Analysis
The issue is caused by element.focus() calls in the cursor positioning system that don't use { preventScroll: true }. When the browser focuses an element that's below the visible viewport, it automatically scrolls to make it visible.
Key files involved:
packages/desktop-app/src/lib/design/components/textarea-controller.svelte.ts - focus() method at line ~434
packages/desktop-app/src/lib/services/cursor-positioning-service.ts - multiple textarea.focus() calls
Proposed Solution
Add { preventScroll: true } to focus calls, but this needs careful manual testing because:
- Our unit tests use mocked DOM and don't detect real browser focus/scroll behavior
- Cursor positioning has broken multiple times in the past without test detection
- The change affects all focus operations (Enter key, arrow navigation, node creation, etc.)
Testing Requirements
Before implementing, manually test these scenarios:
Related
- Scroll state management:
packages/desktop-app/src/lib/stores/scroll-state.ts
- Base node viewer scroll restoration:
base-node-viewer.svelte lines 323-334
Problem
When opening a new tab to view a root node, the scroll position is not at the top of the document. Users have to manually scroll up to see the beginning of the content.
Root Cause Analysis
The issue is caused by
element.focus()calls in the cursor positioning system that don't use{ preventScroll: true }. When the browser focuses an element that's below the visible viewport, it automatically scrolls to make it visible.Key files involved:
packages/desktop-app/src/lib/design/components/textarea-controller.svelte.ts-focus()method at line ~434packages/desktop-app/src/lib/services/cursor-positioning-service.ts- multipletextarea.focus()callsProposed Solution
Add
{ preventScroll: true }to focus calls, but this needs careful manual testing because:Testing Requirements
Before implementing, manually test these scenarios:
Related
packages/desktop-app/src/lib/stores/scroll-state.tsbase-node-viewer.sveltelines 323-334