Skip to content

feat: add scrollbar to Table of Contents for long articles#288

Open
vaani1127 wants to merge 4 commits intokeploy:mainfrom
vaani1127:feat/toc-scrollbar
Open

feat: add scrollbar to Table of Contents for long articles#288
vaani1127 wants to merge 4 commits intokeploy:mainfrom
vaani1127:feat/toc-scrollbar

Conversation

@vaani1127
Copy link
Copy Markdown

This PR adds a scrollbar to the Table of Contents component to improve usability for long articles.

Changes

  • Modified components/TableContents.tsx to add scrollbar functionality

Why

  • Prevents TOC from taking up excessive vertical space
  • Improves navigation experience for articles with many headings

@dhananjay6561
Copy link
Copy Markdown
Member

Hey @vaani1127 👋 — thanks so much for contributing to the project, really appreciate it!

Your PR looks great and has been marked for merging. Here's a quick note from the reviewer:

Adds max-h-[80vh] overflow-y-auto + fixes indentation. Close #275 as duplicate.

We'll get this merged in soon. Keep the great work coming! 🚀

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds vertical scrolling to the desktop Table of Contents so very long heading lists don’t expand indefinitely, improving navigation for long articles.

Changes:

  • Makes the desktop TOC <nav> scrollable via a max-height and overflow-y-auto.
  • Minor formatting/indentation cleanup in handleItemClick.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread components/TableContents.tsx Outdated
Comment on lines 205 to 206
<nav ref={tocRef} className="max-h-[80vh] overflow-y-auto pr-2">
<ul className="pl-0 leading-5">
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

Adding max-h-[80vh] overflow-y-auto to the TOC container changes tocRef.current.clientHeight to be capped at ~80vh, so the resizeHandler effect (which sets isList when clientHeight > window.innerHeight * 0.8) will never flip isList to true for long TOCs. This effectively makes the large-screen <select> fallback and the isList-based layout tweaks in components/post-body.tsx unreachable/always-false. If you still want isList to represent “content overflows”, compare scrollHeight vs clientHeight (or scrollHeight > clientHeight) instead; otherwise, consider removing the isList sizing effect/prop to avoid misleading state.

Suggested change
<nav ref={tocRef} className="max-h-[80vh] overflow-y-auto pr-2">
<ul className="pl-0 leading-5">
<nav className="max-h-[80vh] overflow-y-auto pr-2">
<ul ref={tocRef} className="pl-0 leading-5">

Copilot uses AI. Check for mistakes.
Signed-off-by: vaani1127 <vprashar_be23@thapar.edu>
Signed-off-by: vaani1127 <vprashar_be23@thapar.edu>
@vaani1127 vaani1127 force-pushed the feat/toc-scrollbar branch from 9da8fba to 7737ef1 Compare April 8, 2026 09:51
vaani1127 and others added 2 commits April 8, 2026 15:22
Signed-off-by: Vaani Prashar <147430351+vaani1127@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants