Skip to content

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

Closed

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

Activity

  1. added
    bug
    on Feb 1, 2026
  2. malibio commented on Feb 1, 2026

    @malibio
    CollaboratorAuthor

    Test baseline: Frontend 3501 passed (104 files), Rust 751 passed, 2 pre-existing failures (test_add_to_collection_assigns_order, test_node_service_idempotent_seeding)

  3. self-assigned this
    on Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugui

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions