When the “Smooth Scroll (CSS)” option is enabled in Bricks settings, the scroll position for Table of Contents links is incorrect if a heading offset is defined.
Steps to reproduce:
Go to Bricks settings and enable “Smooth Scroll (CSS)”
Add a Table of Contents element
Set “Headings offset (px)” to a value (e.g. 64)
Click on any link in the Table of Contents
Expected behavior:
The page should scroll to the correct heading, taking the defined offset (e.g. 64px) into account.
Actual behavior:
The scroll position is incorrect and does not respect the configured heading offset.
Notes:
The issue appears to be related to how CSS-based smooth scrolling handles offset values. If “Smooth Scroll (CSS)” is disabled, it works as intended.
Could you check if you have any relative wrappers that might affect the scrolling position (as described in the mentioned threads), or provide a link or login credentials (via email)?
The page uses a <header> with position:sticky, <main> and <footer> with position:relative.
I tested removing position:sticky from the header and changing position:relative to position:static on both and via the browser’s developer tools. However, the issue still persists, so it does not seem to be directly caused by these positioning rules.
This checks whether a data-smooth-scroll="1" attribute exists anywhere in the HTML (it does—in the toc element) and, if so, resets the CSS smooth scroll to auto to prevent it from conflicting with the toc JavaScript smooth scroll.
That’s right, it couldn’t go much better
I’m really glad the solution works. I’ll suggest this in the other thread(s) as well—as far as I can see, there’s no reason not to implement it natively.
actually my post was regarding another problem, namely the highlighting of the ToC links. The state class »is-active-li« doesn’t get assigned if the container element of the targeted Headline is set to position:relative. Please check if you can reproduce this behavior.
The scrolling position of the content is working fine in my case.
Hi @benjamin,
I know what your report was (and still is) about, and Matej confirmed it back then—but it doesn’t hurt to ask, since the problem could be related.
But if that’s not the case: no problem I’m sorry we haven’t been able to resolve your issue yet.