You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using an offcanvas component, closing it (either via the close button or by clicking on the backdrop) unexpectedly scrolls the page to the top — but only when the following CSS rule is applied:
html,body {
scroll-padding-top:100px;
}
This seems to be a Chromium-specific issue.
To Reproduce
Steps to reproduce the behavior:
Add scroll-padding-top: 100px; to html, body
Add an offcanvas with a toggle and a close button
Scroll the page down
Open the offcanvas
Click on the close button or the backdrop to dismiss it
Observe the page jumps back to the top
Expected behavior
The page scroll position should not change when closing an offcanvas, regardless of scroll-padding-top.
Environment
Bootstrap version: 5.3.7, 5.3.2
Browser:
✅ Firefox: Works correctly, no scroll jump
❌ Chrome (v125+) and Edge (v125+): Scrolls to top when closing offcanvas
OS: Windows
Removing scroll-padding-top fixes the issue: the scroll position remains unchanged after closing the offcanvas.
Prerequisites
Describe the issue
When using an offcanvas component, closing it (either via the close button or by clicking on the backdrop) unexpectedly scrolls the page to the top — but only when the following CSS rule is applied:
This seems to be a Chromium-specific issue.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The page scroll position should not change when closing an offcanvas, regardless of scroll-padding-top.
Environment
Removing scroll-padding-top fixes the issue: the scroll position remains unchanged after closing the offcanvas.
Reduced test cases
Codepen => https://codepen.io/David-Henriet/pen/GgpqLrm
bt-offcanvas-ezgif.com-gif-maker.webm
What operating system(s) are you seeing the problem on?
Windows
What browser(s) are you seeing the problem on?
Chrome
What version of Bootstrap are you using?
5.3.7, 5.3.2