-
Notifications
You must be signed in to change notification settings - Fork 191
feat: add scrollbar to table of contents on long articles #275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Anuj Shrivastava <anujshrivastava10e@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a scrollable table of contents (TOC) for long articles on desktop layouts, preventing the TOC from extending beyond the viewport. The implementation restricts the TOC height to 80% of viewport height and enables vertical scrolling when content exceeds this limit.
Changes:
- Added scrolling behavior to the desktop TOC navigation element with Tailwind utility classes
- Applied max-height constraint, overflow scrolling, and padding for scrollbar spacing
Comments suppressed due to low confidence (1)
components/TableContents.tsx:59
- The resizeHandler logic at line 58 checks if
container.clientHeight > window.innerHeight * 0.8to determine whether to show a dropdown list. However, with the newmax-h-[80vh]constraint applied to the nav element, the container's clientHeight will never exceed 80vh (0.8 * window.innerHeight), making this condition always false. This breaks the intended behavior of switching to a dropdown when the TOC is too tall. The logic should check the scrollHeight instead of clientHeight, or the threshold should be adjusted to account for the max-height constraint.
function resizeHandler() {
setIsList(container.clientHeight > window.innerHeight * 0.8);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Anuj Shrivastava <anujshrivastava10e@gmail.com>
Signed-off-by: Anuj Shrivastava <anujshrivastava10e@gmail.com>
amaan-bhati
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @AnujShrivastava01 Thanks for raising this pr, before i review this on local, can you please also share a preview screenshot for how it looks in smaller screen sizes as well?
|
Hii @amaan-bhati Sir, thanks for checking this out! I’ve added preview screenshots for smaller screen sizes in the PR description above. The layout has been tested to ensure proper spacing, alignment, and responsiveness on mobile and small-width viewports. |
|
@amaan-bhati Sir, please review the changes. Thank you. |
|
@Achanandhi-M Sir, please review the PR. Thank you. |



Pull Request: Add Scrollbar to Table of Contents
Description
Implements a scrollable Table of Contents component for long articles, improving user experience by allowing independent scrolling of TOC without affecting page scroll position.
Fixes keploy/keploy#3543
🔧 Changes Made
max-h-[80vh]to limit TOC height to 80% of viewport heightoverflow-y-autoto enable scrollbar when content exceeds max heightpr-2for proper scrollbar spacing and paddingFiles Changed
components/TableContents.tsxTesting
Screenshots/Preview
Before: TOC extends beyond viewport without scrollbar

After: TOC has scrollbar when content exceeds 80vh

Checklist