Skip to content

TOC on public notes closes on interaction #35

@rui-typelets

Description

@rui-typelets

Description:
The Table of Contents on public notes closes immediately when scrolling the page or clicking anywhere, making it difficult to use for navigation.

Expected behavior:
The TOC should stay open after being expanded until the user explicitly clicks the TOC header to collapse it. Scrolling or clicking TOC links should not close it.

Actual behavior:
Once you open the TOC, any interaction (scrolling, clicking links, clicking anywhere on the page) causes it to close immediately, requiring you to reopen it each time.

Steps to reproduce:

  1. Open a public note with a Table of Contents
  2. Click the TOC header to expand it
  3. Scroll the page or click a TOC link
  4. Observe the TOC collapsing automatically

Root cause:
TOC state was managed via DOM class manipulation which gets reset when React re-renders (e.g., from scroll state changes).

Fix:
Use React state (useState) to persist the expanded/collapsed state across re-renders instead of relying on DOM manipulation.

Metadata

Metadata

Assignees

Labels

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions