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:
- Open a public note with a Table of Contents
- Click the TOC header to expand it
- Scroll the page or click a TOC link
- 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.
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:
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.