Skip to content

Fix: New tab opens with scroll position not at top #860

Description

@malibio

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:

  1. Our unit tests use mocked DOM and don't detect real browser focus/scroll behavior
  2. Cursor positioning has broken multiple times in the past without test detection
  3. The change affects all focus operations (Enter key, arrow navigation, node creation, etc.)

Testing Requirements

Before implementing, manually test these scenarios:

  • Enter key creates new node - cursor should be in new node
  • Arrow up/down navigation between nodes
  • Clicking on a node to edit
  • Creating a node via slash command
  • Tab switching preserves scroll position
  • New tab opens at scroll top
  • Indent/outdent operations
  • Node type conversion (text → task, etc.)

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingui

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions