Skip to content

feat: update scrollspy and fix active links#3708

Open
MaxLardenois wants to merge 7 commits into
mainfrom
main-ml-update-scrollspy-and-fix-active-links
Open

feat: update scrollspy and fix active links#3708
MaxLardenois wants to merge 7 commits into
mainfrom
main-ml-update-scrollspy-and-fix-active-links

Conversation

@MaxLardenois

@MaxLardenois MaxLardenois commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Types of change

  • Non-breaking change
  • Breaking change (fix or feature that would change existing functionality and usage)

Context & Motivation

  • Scrollspy is buggy and was updated with native IntersectionObserver in Bootstrap v6
  • issue on documentation pages without TOC : the active links were automatically deactivated by scrollspy

Description

⚠️ the parent selectors (to activate link's "parents" too) have been modified from the one in Bootstrap because our TOC do not use Bootstrap nav / nav-link. We will need to revisit this when implementing Scrollspy for our users. See #3711

Checklists

  • I have read the contributing guidelines
  • My change follows the developer guide
  • My change pass all tests
  • My change is compatible with a responsive display
  • I have added tests (Javascript unit test or visual) to cover my changes
  • My change introduces changes to the documentation that I have updated accordingly
    • Title and DOM structure is correct
    • Links have been updated (title changes impact links)
    • CSS for the documentation
  • I have checked all states and combinations of the component with my change
  • I have checked all the impacts for the other components and core behavior (grid, reboot, utilities)

Checklist (for Core Team only)

  • The changes need to be in the migration guide
  • The changes are well displayed in Storybook (be careful if example order has changed for DSM)
  • The changes are compatible with RTL
  • Manually test browser compatibility with BrowserStack (Chrome 120, Firefox 121, Edge 120, Safari 15.6, iOS Safari, Chrome & Firefox on Android)

Progression (for Core Team only)

Live previews

@netlify

netlify Bot commented Jul 22, 2026

Copy link
Copy Markdown

Deploy Preview for boosted ready!

Name Link
🔨 Latest commit 64bba30
🔍 Latest deploy log https://app.netlify.com/projects/boosted/deploys/6a61d91b9dd0860008a702b0
😎 Deploy Preview https://deploy-preview-3708--boosted.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@MaxLardenois
MaxLardenois marked this pull request as ready for review July 22, 2026 19:45
@boosted-bot boosted-bot moved this from In Progress / Draft to Need Dev Review in 🟣 [Orange-Boosted-Bootstrap] PRs Board Jul 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates the ScrollSpy implementation to an IntersectionObserver-driven approach (closer to Bootstrap v6), adjusts documentation behavior so pages without a Table of Contents don’t enable ScrollSpy, and tightens some site typing/export details.

Changes:

  • Refactors js/src/scrollspy.js to use IntersectionObserver state for active section detection, adds topMargin option, and adds smooth-scroll settle (hash + focus) behavior.
  • Marks many docs pages as toc: false so ScrollSpy isn’t enabled on pages without a TOC.
  • Exposes DataType for typed sidebar loading and adjusts docs sidebar logic accordingly.

Reviewed changes

Copilot reviewed 41 out of 41 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
site/src/libs/icon.ts Makes height/width optional for SVG icon props.
site/src/libs/data.ts Exports DataType for typed getData() call sites.
site/src/layouts/DocsLayout.astro Enables ScrollSpy only when toc is true; sets ScrollSpy top activation line via data-bs-top-margin.
site/src/content/docs/layout/form-layout.mdx Sets toc: false to avoid enabling ScrollSpy without TOC.
site/src/content/docs/getting-started/webpack.mdx Sets toc: false.
site/src/content/docs/getting-started/vite.mdx Sets toc: false.
site/src/content/docs/getting-started/rtl.mdx Sets toc: false.
site/src/content/docs/getting-started/parcel.mdx Sets toc: false.
site/src/content/docs/getting-started/optimize.mdx Sets toc: false.
site/src/content/docs/getting-started/component-versioning.mdx Sets toc: false.
site/src/content/docs/foundation/images.mdx Sets toc: false.
site/src/content/docs/components/tooltip.mdx Sets toc: false.
site/src/content/docs/components/toast.mdx Sets toc: false.
site/src/content/docs/components/title-bar.mdx Sets toc: false.
site/src/content/docs/components/sticker.mdx Sets toc: false.
site/src/content/docs/components/stepped-process.mdx Sets toc: false.
site/src/content/docs/components/spinner.mdx Sets toc: false.
site/src/content/docs/components/scrollspy.mdx Sets toc: false.
site/src/content/docs/components/range.mdx Sets toc: false.
site/src/content/docs/components/quantity-selector.mdx Sets toc: false.
site/src/content/docs/components/progress.mdx Sets toc: false.
site/src/content/docs/components/popover.mdx Sets toc: false.
site/src/content/docs/components/pagination.mdx Sets toc: false.
site/src/content/docs/components/offcanvas.mdx Sets toc: false.
site/src/content/docs/components/navbar.mdx Sets toc: false.
site/src/content/docs/components/nav-tab.mdx Sets toc: false.
site/src/content/docs/components/modal.mdx Sets toc: false.
site/src/content/docs/components/local-navigation.mdx Sets toc: false.
site/src/content/docs/components/list-group.mdx Sets toc: false.
site/src/content/docs/components/dropdown.mdx Sets toc: false.
site/src/content/docs/components/collapse.mdx Sets toc: false.
site/src/content/docs/components/close-button.mdx Sets toc: false.
site/src/content/docs/components/carousel.mdx Sets toc: false.
site/src/content/docs/components/card.mdx Sets toc: false.
site/src/content/docs/components/back-to-top.mdx Sets toc: false.
site/src/content/docs/components/accordion.mdx Sets toc: false.
site/src/components/DocsSidebar.astro Refactors sidebar selection and attempts to type sidebar data via Zod schema inference.
js/tests/unit/scrollspy.spec.js Updates and expands unit tests for new ScrollSpy behavior and options.
js/src/scrollspy.js Major ScrollSpy refactor: IO-based active detection, activation line config, sentinel bottom handling, smooth-scroll settle logic, and stricter target requirement.
js/src/dom/event-handler.js Adds scrollend to the native event allowlist.
.bundlewatch.config.json Updates bundle size thresholds to account for ScrollSpy code growth.

Comment thread js/src/scrollspy.js
Comment on lines +436 to +438
_getSettleTarget() {
return this._rootElement || document
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The smooth scroll should be investigated, maybe it's not useful in a OUDS context, also removing it would make the file smaller.
Will keep as is to be as close as possible to Bs6

Comment thread site/src/components/DocsSidebar.astro Outdated
Comment thread site/src/layouts/DocsLayout.astro Outdated

@louismaximepiton louismaximepiton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How should it behaves while having the dual-mode ?
Maybe we should explore with Jerome some designs that we could have for the nesting styles.
I feel like it's quite weird right now.

Image

@MaxLardenois

MaxLardenois commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator Author

How should it behaves while having the dual-mode ?

It should be a drop-in replacement, as in: it will just work better

Maybe we should explore with Jerome some designs that we could have for the nesting styles. I feel like it's quite weird right now.
Image

We could, but I do not think it's blocking.
Your example do not really shock me tbh, I prefer that than what we had before at any rate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Need Dev Review

Development

Successfully merging this pull request may close these issues.

4 participants