Skip to content

Conversation

@Telucero
Copy link
Contributor

@Telucero Telucero commented Sep 8, 2025

Description

This script improves the table of contents (TOC) behavior for MkDocs-based documentation sites. It ensures that both the left and right navigation TOCs highlight the correct heading as the user scrolls or clicks anchor links.

Related to Tanssi Mkdocs 87

Checklist

  • I have added a label to this PR 🏷️
  • I have run my changes through Grammarly
  • If this page requires a disclaimer, I have added one
  • If pages have been moved around, I have created an additional PR in tanssi-mkdocs to update redirects

Copilot AI review requested due to automatic review settings September 8, 2025 15:23
@Telucero Telucero requested a review from a team as a code owner September 8, 2025 15:23
Copy link
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

This PR adds a JavaScript script to fix table of contents (TOC) scrolling behavior for MkDocs-based documentation sites. The script ensures proper highlighting of TOC items and smooth scrolling with header offset compensation.

  • Implements smooth scrolling with header offset when clicking anchor links
  • Updates TOC highlighting based on current scroll position
  • Adds periodic verification to handle delayed rendering scenarios

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-actions
Copy link

github-actions bot commented Sep 8, 2025

Style Guide Violations Summary

js/fix-toc-scroll.js (Line 1)

  • Issue:
    JavaScript should use single quotes for string literals per style guide

  • Correction:

document.addEventListener('DOMContentLoaded', () => {

js/fix-toc-scroll.js (Line 2)

  • Issue:
    Non-exported constants should use camelCase per style guide

  • Correction:

const scrollOffset = 80; // Adjust based on your header height

js/fix-toc-scroll.js (Line 3)

  • Issue:
    Non-exported constants should use camelCase per style guide

  • Correction:

const tocSelectorLeft = '.md-nav__link'; // Left nav links

js/fix-toc-scroll.js (Line 4)

  • Issue:
    Non-exported constants should use camelCase per style guide

  • Correction:

const tocSelectorRight = '.md-nav__item--active ~ .md-nav__link'; // Adjust for right nav if you have one

@github-actions
Copy link

github-actions bot commented Sep 8, 2025

Verification Review

This review focuses on style guide claims, justifications, and confidence scores in the provided documents.


Unknown (Line -1)

  • Claim:

  • Context:

  • Justification:

(none provided)

  • Requires Verification: No
  • Confidence Score: 0

@Telucero Telucero added A2 - Maintenance Minor Pull request contains minor updates to an existing page (i.e., modifying parameters, steps, etc.) B0 - Needs Review Pull request is ready for review labels Sep 8, 2025
@eshaben eshaben marked this pull request as draft September 17, 2025 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A2 - Maintenance Minor Pull request contains minor updates to an existing page (i.e., modifying parameters, steps, etc.) B0 - Needs Review Pull request is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants