Skip to content

No view has keyboard focus on app launch #1916

@gjouret

Description

@gjouret

Bug Description

When FSNotes launches, no view has keyboard focus. The last-viewed note is displayed correctly, but the folder in the sidebar is grayed out, the note in the notes list is grayed out, and no pane responds to keyboard input until the user clicks somewhere.

Steps to Reproduce

  1. Open FSNotes
  2. Observe the sidebar and notes list — both selections are gray (unfocused)
  3. Press Up/Down arrow keys — nothing responds

Expected Behavior

On launch, the notes list should have keyboard focus (blue selection), allowing immediate keyboard navigation.

Actual Behavior

No view is first responder. All selections appear gray/unfocused. The user must click on a pane before keyboard navigation works.

Root Cause

In ViewController.swift, neither viewDidLoad() nor viewDidAppear() sets an initial first responder. The storyboard's initialFirstResponder outlet is not connected, so AppKit has no default target.

Proposed Fix

Set focus to the notes list inside configureNoteList(), after the updateTable completion handler finishes loading content. This must be placed inside the async completion — not in viewDidAppear() or after the configureNoteList() call — because updateTable() loads data asynchronously and dispatches back to the main queue:

private func configureNoteList() {
    updateTable() {
        DispatchQueue.main.async {
            // ... existing welcome note and window restore code ...

            // Set initial focus to notes list after content is loaded
            NSApp.mainWindow?.makeFirstResponder(self.notesTableView)

            // ... existing preLoadProjectsData call ...
        }
    }
}

Placing makeFirstResponder anywhere earlier (e.g. viewDidAppear, or synchronously after configureNoteList()) has no effect because the table has no content yet — updateTable hasn't completed.

Environment

  • macOS
  • FSNotes latest (main branch)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions