Skip to content

feat(toc): highlight active heading while scrolling#9727

Open
SiriusXT wants to merge 15 commits into
mainfrom
toc_scroll_active
Open

feat(toc): highlight active heading while scrolling#9727
SiriusXT wants to merge 15 commits into
mainfrom
toc_scroll_active

Conversation

@SiriusXT
Copy link
Copy Markdown
Member

@SiriusXT SiriusXT commented May 14, 2026

It is disabled by default and can be enabled in the options.

preview2

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements auto-scrolling for the Table of Contents and PDF page thumbnails to ensure the active item remains visible. Feedback indicates that the current implementation in PdfPageCell will not work for off-screen items due to the use of a virtualized list, and suggests moving the scroll logic to the parent component. Additionally, it is recommended to change the scroll alignment from center to nearest to prevent unnecessary or disruptive UI jumping when an item is already partially visible.

Comment thread apps/client/src/widgets/sidebar/pdf/PdfPages.tsx Outdated
Comment thread apps/client/src/widgets/sidebar/TableOfContents.tsx Outdated
Comment thread apps/client/src/widgets/sidebar/pdf/PdfPages.tsx Outdated
@SiriusXT SiriusXT force-pushed the toc_scroll_active branch from 075de9b to b23d018 Compare May 16, 2026 06:54
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 16, 2026

🖥️ App preview is ready!

🔗 Preview URL: https://pr-9727.trilium-app.pages.dev
📖 Production URL: https://app.triliumnotes.org

✅ All checks passed

This preview will be updated automatically with new commits.

@SiriusXT SiriusXT changed the title feat(right_pane): keep active entry visible via auto-scroll feat(toc): highlight active heading while scrolling May 16, 2026
@SiriusXT
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a feature to synchronize the Table of Contents with the currently viewed heading in text notes, adding a configuration toggle and automatic scrolling to the active TOC item. Feedback suggests improving the active heading detection by calculating the trigger position dynamically to handle layout changes, reducing the scroll debounce timer for better responsiveness, and fixing a minor syntax typo in a type declaration.

Comment thread apps/client/src/widgets/sidebar/TableOfContents.tsx Outdated
Comment thread apps/client/src/widgets/sidebar/TableOfContents.tsx Outdated
Comment thread apps/client/src/widgets/sidebar/TableOfContents.tsx Outdated
@SiriusXT SiriusXT marked this pull request as ready for review May 17, 2026 02:24
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 17, 2026
@SiriusXT SiriusXT marked this pull request as draft May 18, 2026 15:43
@SiriusXT
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements an "active heading" synchronization feature for the Table of Contents (TOC), allowing the sidebar to highlight and scroll to the heading currently being viewed. The implementation includes a new configuration modal, updated translations, and logic to support both editable and read-only note types. Additionally, it fixes a bug where TOC IDs could be duplicated and ensures headings from included notes are excluded from the TOC. Review feedback identifies a type mismatch in a React ref, the use of a magic number for scroll offsets, and a missing dependency in a useEffect hook. Suggestions were also provided to use passive event listeners for scroll performance and to adhere to camelCase naming conventions for state setters.

Comment thread apps/client/src/widgets/sidebar/TableOfContents.tsx Outdated
Comment thread apps/client/src/widgets/sidebar/TableOfContents.tsx
Comment thread apps/client/src/widgets/sidebar/TableOfContents.tsx
Comment thread apps/client/src/widgets/sidebar/TableOfContents.tsx
Comment thread apps/client/src/widgets/sidebar/TableOfContents.tsx Outdated
@SiriusXT SiriusXT marked this pull request as ready for review May 23, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant