Skip to content

j/k navigation only cycles through h2 headings, ignoring expanded subsections #16

@kookyleo

Description

@kookyleo

Bug Report

Description

The j/k keyboard navigation only cycles through h2 level headings and does not navigate into subsections (h3, h4, etc.) even when those subsections are expanded.

Current Behavior

  • Press j to navigate to next section → jumps to next h2
  • Press k to navigate to previous section → jumps to previous h2
  • Expanded subsections (h3, h4, h5, h6) are skipped
  • Navigation only works at the top level (h2)

Expected Behavior

When subsections are expanded:

  • j should navigate to the next visible heading (h2, h3, h4, etc.)
  • k should navigate to the previous visible heading
  • Navigation should follow the visual document hierarchy
  • Collapsed subsections should be skipped (only navigate to their parent)

Example Scenario

## Section 1 (h2) ← j/k navigates here
  ### Subsection 1.1 (h3) ← Should navigate here when expanded, but currently skipped
  ### Subsection 1.2 (h3) ← Should navigate here when expanded, but currently skipped
## Section 2 (h2) ← j/k navigates here
  ### Subsection 2.1 (h3) [collapsed] ← Should be skipped
    #### Subsection 2.1.1 (h4) [hidden] ← Should be skipped
  ### Subsection 2.2 (h3) ← Should navigate here when expanded
## Section 3 (h2) ← j/k navigates here

Steps to Reproduce

  1. Open a document with h2 sections that contain h3/h4 subsections
  2. Expand some subsections so they are visible
  3. Press j or k to navigate
  4. Observe that only h2 headings are selected, h3+ subsections are skipped

Technical Notes

  • Need to query all visible headings, not just h2
  • Should check if heading is within a collapsed section
  • Navigation order should follow DOM order of visible headings
  • May need to filter based on computed styles or parent section state

Related Code

Likely in:

  • Keyboard navigation handler
  • Section navigation logic
  • Heading selector queries (probably using h2 selector instead of h2, h3, h4, h5, h6)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions