Skip to content

Add scroll spy functionality to Table of Contents for better navigation#2190

Draft
Nakshatra480 wants to merge 12 commits intojson-schema-org:mainfrom
Nakshatra480:fix/toc-scroll-spy
Draft

Add scroll spy functionality to Table of Contents for better navigation#2190
Nakshatra480 wants to merge 12 commits intojson-schema-org:mainfrom
Nakshatra480:fix/toc-scroll-spy

Conversation

@Nakshatra480
Copy link

@Nakshatra480 Nakshatra480 commented Jan 31, 2026

Summary

Add scroll spy functionality to the Table of Contents (TOC) to highlight the currently visible section dynamically as the user scrolls through the document.

Changes

  • Added IntersectionObserver to track visible headings (h1–h4) and update the active section dynamically.
  • Updated TableOfContentMarkdown.tsx with minimal modifications and preserved pre existing code structure.
  • Compatibility ensured for light and dark themes.
  • Minimal impact on existing CSS styles or components.

Linked Issues

Closes #2169.

Testing Plan

  1. Run npm run dev and open a page with a TOC.
  2. Ensure that as you scroll through the document, the corresponding TOC item gets highlighted.
  3. Test both light and dark themes for consistency.
  4. Verify proper behavior when clicking on TOC links (navigation and URL hash update).
  5. Perform browser compatibility testing (latest versions of Chrome, Firefox, Safari, and Edge).

Checklist

  • Linked issue included
  • No lint or formatting errors
  • Built without issues
  • No errors in CI checks

Implements Intersection Observer to highlight active sections while scrolling through documentation. Fixes json-schema-org#2169
@github-actions
Copy link

Hi @Nakshatra480! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@github-actions
Copy link

Hi @Nakshatra480! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@github-actions
Copy link

Hi @Nakshatra480! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@github-actions
Copy link

github-actions bot commented Jan 31, 2026

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
website ✅ Ready (View Log) Visit Preview 01cacde

@codecov
Copy link

codecov bot commented Jan 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (974ad0e) to head (01cacde).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #2190   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           30        30           
  Lines          640       640           
  Branches       198       198           
=========================================
  Hits           640       640           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link

Hi @Nakshatra480! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

3 similar comments
@github-actions
Copy link

Hi @Nakshatra480! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@github-actions
Copy link

Hi @Nakshatra480! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@github-actions
Copy link

github-actions bot commented Feb 1, 2026

Hi @Nakshatra480! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@Nakshatra480
Copy link
Author

Hi @AgniveshChaubey @Utkarsh-123github PR is ready, pls review it and give feedback thanks

@AgniveshChaubey
Copy link
Collaborator

image

I still can’t see the highlight effect on the heading in the TOC on the right side.

@github-actions
Copy link

github-actions bot commented Feb 1, 2026

Hi @Nakshatra480! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@github-actions
Copy link

github-actions bot commented Feb 1, 2026

Hi @Nakshatra480! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@github-actions
Copy link

github-actions bot commented Feb 1, 2026

Hi @Nakshatra480! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@github-actions
Copy link

github-actions bot commented Feb 1, 2026

Hi @Nakshatra480! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@github-actions
Copy link

github-actions bot commented Feb 1, 2026

Hi @Nakshatra480! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Hi @Nakshatra480! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Hi @Nakshatra480! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Hi @Nakshatra480! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Hi @Nakshatra480! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Hi @Nakshatra480! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Hi @Nakshatra480! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@Nakshatra480
Copy link
Author

@AgniveshChaubey i have updated the code structure of the TableOfContentMarkdown.tsx file, now you can review the PR thanks for your feedback

@Nakshatra480 Nakshatra480 marked this pull request as ready for review February 2, 2026 07:19
@Nakshatra480
Copy link
Author

ping @AgniveshChaubey

@AgniveshChaubey
Copy link
Collaborator

I still can't see any highlights in the TOC on the right-hand side. Hane you tested the functionality locally? Can you please share a demo video?

@Nakshatra480 Nakshatra480 marked this pull request as draft February 23, 2026 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Ready to review

Development

Successfully merging this pull request may close these issues.

🐛 Bug: Table of Contents should highlight active section while scrolling

2 participants