-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
Open
Description
Prerequisites
- I have searched for duplicate or closed issues
- I have validated any HTML to avoid common problems
- I have read the contributing guidelines
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:
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.
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
Metadata
Metadata
Assignees
Labels
No labels